Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java get enum by ordinal

// Create your enum
enum YourEnum {
   enum1, enum2, enum3, enum4;
   public static final YourEnum[] values = values();
}

// to get your enum by its ordinal, write this wherever in java
YourEnum yourEnum = YourEnum.values[ordinal];
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #enum #ordinal
ADD COMMENT
Topic
Name
9+5 =