Try MyEnum.values()[x]
where x
must be 0
or 1
, i.e. a valid ordinal for that enum.
Note that in Java enums actually are classes (and enum values thus are objects) and thus you can't cast an int
or even Integer
to an enum.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…