The whole question is in the title. For example:
enum enumTest {
TYPE1(4.5, "string1"), TYPE2(2.79, "string2");
double num;
String st;
enumTest(double num, String st) {
this.num = num;
this.st = st;
}
}
The constructor is fine with the default or private modifier, but gives me a compiler error if given the public or protected modifiers.
Think of Enums as a class with a finite number of instances. There can never be any different instances beside the ones you initially declare.
Thus, you cannot have a public or protected constructor, because that would allow more instances to be created.
Note: this is probably not the official reason. But it makes the most sense for me to think of
enumsthis way.