Is it possible for me to convert a String to an equivalent value in an Enumeration, using Java.
I can of course do this with a large if-else statement, but I would like to avoid this if possible.
Given this documentation:
http://download.oracle.com/javase/1.4.2/docs/api/java/util/Enumeration.html
I am not too hopeful that this is possible without ifs or a case statement.
Hope you realise,
java.util.Enumerationis different from the Java 1.5 Enum types.You can simply use
YourEnum.valueOf("String")to get the equivalent enum type.Thus if your enum is defined as so:
You could do this: