forum

Home / DeveloperSection / Forums / Convert a String to an enum in Java

Convert a String to an enum in Java

Samuel Fernandes204208-May-2015
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?

Updated on 08-May-2015

Can you answer this question?


Answer

1 Answers

Liked By