Dave's Brain

Browse - Programming Tips - Java: How can I covert a String to/from an enum?

Date: 2017dec8
Language: java

Q.  Java: How can I covert a String to/from an enum?

A.  String to enum:

MyEnum e = MyEnum.valueOf(mystr);
enum to String:
String str = e.toString();

Add a comment

Sign in to add a comment
Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.