0

Possible Duplicate:
How to convert enum value to int?

I'm trying to assign values to my enums like:

enum it { one=5,two=7};

I can't beleive I can't remember how to do this.

Could someone help me??

Thank you very much

Community
  • 1
  • 1
user565660
  • 1,171
  • 3
  • 20
  • 37
  • check out the [difference between enums in C# and Java](http://stackoverflow.com/a/469315/1106367) for more information. – Adam Sep 06 '12 at 15:35

1 Answers1

6
enum it
{
    one(5), two(7);

    private int value;

    it(int value){this.value = value;}

    public int getValue(){return value;}
};

System.out.println(it.one.getValue());

OUTPUT:

5
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417