Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Enum class question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Enum class question" Watch "Enum class question" New topic
Author

Enum class question

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

If I have an enum defined as follows:


Then somewhere in my code, I have a String value of "INPUT_TYPE_COLOR", is there anyway to give an object the correct CharGroupInputType? I know this syntax is wrong, but something like:



Hope that makes sense. Thanks.


GenRocket - Experts at Building Test Data
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
There is a method available to enums called valueOf that will return the enum constant corresponding to the name of the constant.
[ December 18, 2006: Message edited by: Keith Lynn ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enum class question