fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(
  13. Month.MAY.getMonthOrder()
  14. );
  15. }
  16. }
  17.  
  18. enum Month {
  19. // Enum definition. Passing value to constructor.
  20. JANUARY(1), FEBRUARY(2), MARCH(3), APRIL(4),MAY(5),JUNE(6), JULY(7), AUGUST(8), SEPTEMBER(9), OCTOBER(10), NOVEMBER(11), DECEMBER(12);
  21.  
  22. // Member field.
  23. private int monthOrder;
  24.  
  25. // Constructor.
  26. Month (int monthOrder) {
  27. this.monthOrder = monthOrder;
  28. }
  29.  
  30. // Accessor.
  31. int getMonthOrder() {
  32. return this.monthOrder;
  33. }
  34. }
Success #stdin #stdout 0.09s 38796KB
stdin
Standard input is empty
stdout
5