Is there any way to keep straight integer in Java Enum ?
example: i am working on a Restaurant management system. i want to know what quantity of unit of any food a customer will order (e.g 1,2,5 etc.)
so i added a combo box in my GUI where list of units will be shown as : 1, 2, 3 etc. Now, Java Enum does not allowing me to write the code like this:
public enum UnitEnum {
1,2,3,4,5;
}
What least i can do is writing it as:
public enum UnitEnum {
_1,_2,_3,_4,_5;
}
but it is very much odd looking. Is there any way to make it look like the first one ? ( where there is no under score ).
$or an_. The question is: why not write them:ONE,TWO,...?Collections.unmodifiableSet(new TreeSet<Integer>(Arrays.asList(1, 2, 5)))?