List Enum Constants - Java Language Basics

Java examples for Language Basics:enum

Description

List Enum Constants

Demo Code

public class Main {
  public static void main(String[] args) {
    for(Level s : Level.values()) {
      String name = s.name();/*  w  ww.  java 2 s  .com*/
      int ordinal = s.ordinal();  
      System.out.println(name + "(" + ordinal + ")");
    }
  }
}
enum Level {
    LOW, MEDIUM, HIGH, URGENT;
}

Result


Related Tutorials