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

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -