Search This Blog

Wednesday, 13 August 2014

This program shows how to use Enum in Java.

Enum.java

public enum Enum {// name can be other than 'Enum'
 SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
}

MainClass.java

/**
 * How to use Enumeration in Java
 *
 * Enum in Java
 */
public class MainClass {
 
 public static void main(String[] args){
  System.out.println("Enum in java can be used in this way");
  System.out.println(Enum.FRIDAY);
  System.out.println(Enum.SATURDAY);
 }
}

No comments:

Post a Comment