I have an enum like this:
public enum SomeEnum { ENUM_VALUE1("Some value1"), ENUM_VALUE2("Some value2"), ENUM_VALUE3("Some value3"); }
I need to store the enum values Some value1 , Some value2 and Some ArrayList in an ArrayList .
I can get all the values ββin the array using SomeEnum.values() and SomeEnum.values() over this array and store the value in an ArrayList like this:
SomeEnum values[] = SomeEnum.values(); ArrayList<SomeEnum> someEnumArrayList = new ArrayList<SomeEnum>(); for(SomeEnum value:values) { someEnumArrayList.add(value.getValue()); }
Is there any other method, for example values() , that returns an array Some value1 , Some value2 and Some value3 ?
java arraylist arrays enums
Varun
source share