title: Simulate a class of type enum
body: <p>how can I do to simulate a class of type enum in java &lt;5.0 ..??</p>
  
  <pre><code>public final class Week {
  
      private static final Day[] _week = {Day.MONDAY, Day.TUESDAY, Day.WEDNESDAY, Day.THURSDAY, Day.FRIDAY, Day.SATURDAY, Day.SUNDAY};
  
      public static Day getDayOfWeek(final int index) {
          if (index &gt;= 1 &amp;&amp; index &lt;= 7) {
              return _week[index - 1];
          }
          throw new IndexOutOfBoundsException("Invalid index [1..7]");
      }
  
      public static final class Day {
          public static final Day MONDAY = new Day(1, "Monday");
          public static final Day TUESDAY = new Day(2, "Tuesday");
          public static final Day WEDNESDAY = new Day(3, "Wednesday");
          public static final Day THURSDAY = new Day(4, "Thursday");
          public static final Day FRIDAY = new Day(5, "Friday");
          public static final Day SATURDAY = new Day(6, "Saturday");
          public static final Day SUNDAY = new Day(7, "Sunday");
  
          private int _value;
          private String _name;
  
          private Day(final int value, final String name) {
              _value = value;
              _name = name;
          }
  
          /* (non-Javadoc)
           * @see java.lang.Object#toString()
           */
          public String toString() {
              return "[Day] " + _name;
          }
  
          /* (non-Javadoc)
           * @see java.lang.String#equals(java.lang.Object)
           */
          public boolean equals(Object anObject) {
              Day d = (Day)anObject;
              return _value == d._value;
          }
      }
  
      public static void main(String[] agrs) {
           System.out.println(Week.getDayOfWeek(2));
      }
  }
  </code></pre>