This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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: 15302
    
    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: 15302
    
    6

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enum class question
 
It's not a secret anymore!