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 No built-in pred() and succ() for enumerated types? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "No built-in pred() and succ() for enumerated types?" Watch "No built-in pred() and succ() for enumerated types?" New topic
Author

No built-in pred() and succ() for enumerated types?

Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4474
    
    6

No real question here, just something I thought I'd share and maybe get some comments on.

I was trying to find a way to determine the predecessor and successor of an enumerated type value. Pascal has the Succ() and Pred() functions for ordinal types. However, I couldn't find anything in the standard Enum class and Apache Commons Lang EnumUtils doesn't have anything like that either. Seems like a fairly useful pair of methods to have so I was just wondering why java.lang.Enum doesn't provide pred() and succ()... Did I miss something?

I ended up implementing these myself, along with first() and last(). It was actually pretty short and sweet.


Junilu - [How to Ask Questions] [How to Answer Questions]
 
jQuery in Action, 2nd edition
 
subject: No built-in pred() and succ() for enumerated types?