How to get an enum value from a string value in Java
Asked 07 September, 2021
Viewed 2.7K times
  • 48
Votes

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?

30 Answer