Say I have an enum which is just
public enum Blah {
A, B, C, D
}
and I would like to find the enum value of a string, for example "A"
which would be Blah.A
. How would it be possible to do this?
Is the Enum.valueOf()
the method I need? If so, how would I use this?
转载于:https://stackoverflow.com/questions/604424/how-to-get-an-enum-value-from-a-string-value-in-java