How to get Enum Value from index in Java? -
How to get Enum Value from index in Java? -
i have enum in java:
public enum months { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec }
i want access enum values index, e.g.
months(1) = jan; months(2) = feb; ...
how shall that?
try this
months.values()[index]
java enums
Comments
Post a Comment