How Enum Work and Enum Constants Detail


Enum contants detail is explained in this video. First I discuss basic concepts required to understand Enum constants e.g. public access modifier, what are static and final fields. When we can make private constructor and can we define field of same class type in which it is declared. After these basics, I explained enum constants are just public static final fields of same class/enum type. Whenever we refer to these constants, we refer to same distinct objects stored in main memory. When we assign these references to others, JVM make copy of their reference only, it do not create new objects. Constructor of enum is private, so we can't create new objects of enum type from other classes.

Comments