Search code examples
javaconstructorenumsprivatepackage-private

Java - Difference between private and package-private enum constructor


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)?


Solution

  • According to java docs

    The constructor for an enum type must be package-private or private access.

    but Accroding to the JLS

    If no access modifier is specified for the constructor of an enum type, the constructor is private.

    So there no difference between the package-private and private .