D
Derek Fountain
Newbie one: I have an integer that I want to convert into an enum of
type MyEnum. A cast, like this:
enum MyEnum { INIT, WORKING, FINAL, COMPLETE };
MyEnum value = (MyEnum)intValue;
gives a compile time error. I'd like to use an int of 0 as "INIT", 1 as
"WORKING" and so on. An exception if the int is not in the enumeration
would be logical. My enumeration will contain several hundred values and
this needs to be fast.
Java 5.0 enums can do some pretty clever stuff - surely it can do this?
I can't figure out how though... }
type MyEnum. A cast, like this:
enum MyEnum { INIT, WORKING, FINAL, COMPLETE };
MyEnum value = (MyEnum)intValue;
gives a compile time error. I'd like to use an int of 0 as "INIT", 1 as
"WORKING" and so on. An exception if the int is not in the enumeration
would be logical. My enumeration will contain several hundred values and
this needs to be fast.
Java 5.0 enums can do some pretty clever stuff - surely it can do this?
I can't figure out how though... }