Basic example of Enumeration in Java


Here is the simple program for printing basic example of Enumeration in Java.

Source Code

import java.io.*;
class enums
{
  enum days
  {	
   Sunday,
   Monday,
   Tuesday,
   Wednesday,
   Thursday,
   Friday,
   Saturday,
  };
  public static void main(String args[])
  {
   for(days d :days.values())
   {
    //System.out.print(d+"\n");
    weekend(d);
   }
  }
  public static void weekend(days d)
  {
    if(d.equals(days.Sunday)||d.equals(days.Saturday))
    {
      System.out.print(d+" is Holiday \n ");
    }
    else
    {
      System.out.print(d+" is Working Day \n");
    }
  }
}
To download raw file Click Here

Output

Sunday is Holiday
Monday is Working Day
Tuesday is Working Day
Wednesday is Working Day
Thursday is Working Day
Friday is Working Day
Saturday is Holiday


Learn All in Tamil © Designed & Developed By Tutor Joes