devxlogo

Navigating an enum

Navigating an enum

Enums are predefined place holders in Java. Knowing the contents of an enum will be handy in many instances
Let us look at how to navigate the elements of an enum

public class NavigatingAnEnum
{
   public static void main(String args[])
   {
      NavigatingAnEnum navigatingAnEnum = new NavigatingAnEnum();
      navigatingAnEnum.proceed();
   }
   
   enum Criteria {
      LOW,
      MEDIUM,
      HIGH
   }
   
   private void proceed()
   {
      System.out.println(“Elements of the enum Criteria…”);
      for (Criteria criteria : Criteria.values()) {
         System.out.println(criteria);
      }
   }
}

/*

Expected output:

[root@mypc]# java NavigatingAnEnum
Elements of the enum Criteria…
LOW
MEDIUM
HIGH

*/

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist