Java Enum
Enum is a data type which contains a set of constant values. The Enum can be used for Days, months and directions.
The enum values should be in all capital letter according to Java best practice.
The Java enum constants are static and final implicitly.
Enum can have fields, methods and constructors.
Example:
Below is the sample code for enum creation and print all its value using for loop.
Values(), valueOf() and ordinal() methods are present in java.lang.Eum
values() method will return all values present in enum.
valueOf() method return enum constant
ordinal() will return the enum index similar to as an Array.
OUTPUT:
Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.