How to convert a String into Enum value in Java?

A String value representing a value of a Java enum type can easily be converted by using the static .valueOf() method of the enum:

public enum Test { A,B,C }
String testVariable = "B";
private Test converted = Test.valueOf(testVariable);