This question already has an answer here:
Recently I'm quite oftenly using Enumerations. So I wonder...
Is there any difference between a private Enum constructor and a enum constructor withour any visibility modifier (package-private)?
This question already has an answer here:
Recently I'm quite oftenly using Enumerations. So I wonder...
Is there any difference between a private Enum constructor and a enum constructor withour any visibility modifier (package-private)?
According to java docs
but Accroding to the JLS
So there no difference between the package-private and private .
The constructor for enums is implicitly
private
, just like methods for interfaces and annotations are implicitlypublic abstract
. The default is package local for class members.BTW enum classes are implicitly
final
and nested enum classes are implicitlystatic
.Older constructs tend to allow you to add implicit modifiers, but newer constructs don't allow you to say. e.g. enums are final but you can't add
final
to an enum.