posted 13 years ago
Enums are classes. The compiler just treats them a little special. Their constructors are the same. The difference is in how the instances can be created. Class instances are created using the new operator by any other code that has access to the class (and a couple other ways that are not relevant to this conversation). The compiler prevents you from using the new operator on enums (it adds protection even greater than defining a constructor as private).
The compiler (under the covers) defines and initialises one static final reference for each enum element that you define. For example, you defined an enum called Color and defined the Color elements RED, WHITE, and BLUE (well, I changed the colors for the good ol' USA). Then only three static final references are defined and initialized by the compiler. So enum instances are created the same as any other object that must be assigned to a static reference - before any code uses the class (or enum).
As an illustration of enums being classes, I modified your code as follows. As you mentioned, there can be multiple constructors. One constructor can even call the other one. An enum can override methods and can even have a main() method. To show when enum instances are created I modified the printlns to illustrate.
BTW, the static final instances are also the reason why you can use the == operator to compare two enum references.
Also BTW, I started to answer your question and then got carried away. I hope I did not add confusion.