title: What are the differences between a Java enum and a class with private constructor?
body: <p>I was trying to understand how Java enum really works and I have come to the conclusion that it is very similar to a normal Java class that has its constructor declared private.</p>
  
  <p>I have just come to this conclusion and it isn't based on much thinking, but Id like to know whether I miss anything.</p>
  
  <p>So below is an implementation of a simple Java enum and an equivalent Java class.</p>
  
  <pre><code>public enum Direction {
      ENUM_UP(0, -1),
      ENUM_DOWN(0, 1),
      ENUM_RIGHT(1, 0),
      ENUM_LEFT(-1, 0);
  
  
      private int x;
      private int y;
  
      private Direction(int x, int y){
          this.x = x;
          this.y = y;
      }
      public int getEnumX(){
          return x;
      }
      public int getEnumY(){
          return y;
      }
  }
  </code></pre>
  
  <p>What is the difference in meaning between the code above and below?</p>
  
  <pre><code>public class Direction{
      public static final Direction UP = new Direction(0, -1) ;
      public static final Direction DOWN = new Direction(0, 1) ;
      public static final Direction LEFT = new Direction(-1, 0) ;
      public static final Direction RIGHT = new Direction(1, 0) ;
  
  
      private int x ;
      private int y ;
  
      private Direction(int x, int y){
          this.x = x ;
          this.y = y ;
      }
      public int getX(){
          return x;
      }
      public int getY(){
          return y;
      }
  }
  </code></pre>