Answers for "java enum value by ordinal"

1

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];
Posted by: Guest on July-02-2021
1

java get enum by ordinal

YourEnum yourEnum = YourEnum.values()[ordinal];
Posted by: Guest on July-02-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language