This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Enum values by 'string value' 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 values by Watch "Enum values by New topic
Author

Enum values by 'string value'

Luc Lieber
Greenhorn

Joined: May 17, 2010
Posts: 14

Before I get flooded with "just use a map" replies, let me just say that I've always wondered if Java supports this type of operation

It's a bit hard for me to explain...but I want to produce these results:



//Loaded in the following array with my parser class



I hope this question isn't too cryptic...but I've been trying everything to no avail.

Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I think that you can use the java.lang.Enum#valueOf method to do that.


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

After reading your post once again, I may have misunderstood what you want to do. Do yo mean that "enum test" does not exist, and you want to dynamically create it ?
Luc Lieber
Greenhorn

Joined: May 17, 2010
Posts: 14

After banging my head against a wall til now I've kind of lost interest to see if this is possible to do, sorry for wasting the time.
 
GeeCON Prague 2014
 
subject: Enum values by 'string value'