List of enum values in java

后端 未结 6 843
甜味超标
甜味超标 2021-02-01 01:25

Is it possible to create ArrayList of enum values (and manipulate it)? For example:

enum MyEnum
{
   ONE, TWO
}

MyEnum my = MyEnum.ONE;
List  al = new          


        
6条回答
  •  既然无缘
    2021-02-01 01:35

    An enum is just another class in Java, it should be possible.

    More accurately, an enum is an instance of Object: http://docs.oracle.com/javase/6/docs/api/java/lang/Enum.html

    So yes, it should work.

提交回复
热议问题