Java Data Type How to - Store enum in ArrayList








Question

We would like to know how to store enum in ArrayList.

Answer

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main (String[] args) {
        List<MyEnum> enums = new ArrayList<MyEnum>();
    }

    enum MyEnum { ONE, TWO, THREE;}
    //         no need for that  ^ but added to match your question
}