Java: Creating a enum and converting from a string to the Enum

Here is a simple example of how create a Enum and how to convert from a String to the Enum (the common reason for doing this would be is we at some point have for OurEnum.toString() and now wishes to get back to the OurEnum)

First we need to create the Enum, and this needs to be in its own file

public enum OurEnum { ENUM_A, ENUM_B, ENUM_C }

When we then later on (for instace have saved the toString value in a xml file) wish to

String ourEnumAsAString = "ENUM_A"; //replace with code to read the value
OurEnum ourEnum = OurEnum.valueOf(ourEnumAsAString);