ordinal « enum « Java Data Type Q&A

1. Can I specify ordinal for enum (java)?    stackoverflow.com

The ordinal() method can get the ordinal of a enum instance. How can I set the ordinal for a enum ?

2. Creating console command list - how to do it right with Java    stackoverflow.com

For a homework I code in Java(with which I'm a newbie), I bump into the problem of creating a console command list. The user will be confronted with a set of ...

3. Using Enum's ordinal value in switch-case statement    stackoverflow.com

For my project I am using enums, and I need to implement the switch-case statement, where ordinal numbers of values of the specific Enum are checked, like this way:


4. How do I select a specific enum.ordinal() using another enum?    stackoverflow.com

First, my code (It is far from perfect, I don't really know what I am doing) is this:

   public enum Chord { MAJOR, MINOR, DIMINISHED, BASS, BASS2 }

5. Get Enum By Ordinal    coderanch.com

6. Start java enum ordinal at 1 instead of 0    coderanch.com

Note that using the ordinal values of an enum isn't really "safe" with regard to maintenance of your code, because you're tightly tying your source code to values that might have meaning to the business logic. Suppose that you're storing ordinal values in a database. Someday you edit your enum and you add a new constant. // Suppose you first had ...

7. retrieve the ordinal in a enum    forums.oracle.com

I think we'll all be better able to help you if you can give us a paragraph or two describing what you are trying to do in non-programming terms. If we know the problem better, then we can help understand your code perhaps, and be better able to provide a solution. Edited by: Encephalopathic on Sep 12, 2009 11:42 AM