Elements HAPPY("HAPPY"),RAhul("RAhul"),ANSAL("ANSAL"); are created when the enumeration class is loaded (i.e., their scope is static). Enumerations are compiled into regular classes that extend java.lang.Enum , and its instances are allocated on the heap, like other class objects.
Each member invokes a constructor, which is defined in the enumeration, which takes a string parameter.
This is from the corresponding section in the Java Language Specification :
The enumeration constant can be followed by arguments that are passed to the constructor of the enum type when the constant is created during class initialization, as described later in this section. The called constructor is selected using the normal overload rules (ยง15.12.2). If arguments are omitted, an empty argument list is assumed.
source share