Possible Duplicate:
How to get Enum Value from index in Java?
i have a enum like:
public enum EnumTest {
ONE, TWO, THREE
}
how i have a integer like 1=ONE 2=TWO 3=THREE
now i get a integer like 2 and want to generate the EnumTest from it and it should return TWO
how to do this?
You need to associate the
intwith aenumvalue.You can do
or
or use a Map.