enumerated constants - how to
Posted on 2004-11-05
Is there any better way to create enumerated constants in Java?
Assume I would like to create an enumeration for the list of cars I own, what I am currently doing is:
static final int FORD=1;
static final int TOYOTA = 2;
static final int JEEP = 3;
this would serve me well if the enumeration does not change over time (sell or buy cars). However, if it changes, the chance is I may have to go over the code and change some of the details to reflect the modification as well. Is there any way to create an enumeration in a more robust way?