Private enum constructor

Solution 1:

A private constructor only allows objects to be constructed from within the class definition. Being an enum, it is easy to get confused, so I usually find it easier to think of an enum as a class with some special features. So when you write:

SLocale.EN_US

Basically, the parameters

Locale.US, "www.abc.com", "www.edc.com", "www.vvv.com", "www.earn.com"

will be passed to the private constructor so that the enum can be instantiated. Enum constructors have to be private.

Solution 2:

From: http://download.oracle.com/javase/tutorial/java/javaOO/enum.html

Note: The constructor for an enum type must be package-private or private access. It automatically creates the constants that are defined at the beginning of the enum body. You cannot invoke an enum constructor yourself.

You cannot actually have a public enum constructor.

Solution 3:

You need this constructor to be private, because enums define a finite set of values (for example EN_US, EN_UK, FR_FR, FR_BE). If the constructor was public people could potentially create more values (for example invalid/undeclared values such as XX_KK, etc). This would extend the set of initially declared values.