title: How are enums translated during compilation and how are the objects created
body: <pre><code>enum icecream {
      vanilla(100), strawberry(20);
      int price;
  
      icecream(int i) {
          price = i;
      }
  
  }
  </code></pre>
  
  <p>I am a little confused as to how the enum objects are created during compilation time</p>
  
  <p>I saw some examples where they mentioned it like this</p>
  
  <pre><code>public enum Flavor
  {
      COFFEE, VANILLA, CHOCOLATE, STRAWBERRY, RUM_RAISIN, PEACH
  }
  </code></pre>
  
  <p>This gets translated into(during compilation)</p>
  
  <pre><code>public final class Flavor
  extends java.lang.Enum
  {
      public static final Flavor COFFEE = new Flavor("COFFEE", 0);
      public static final Flavor VANILLA = new Flavor("VANILLA", 1);
      // ...
  }
  </code></pre>
  
  <p>Link: <a href="http://www.kdgregory.com/index.php?page=java.enum" rel="nofollow">http://www.kdgregory.com/index.php?page=java.enum</a></p>
  
  <p>But how are the objects created when I pass a value along with the name cause to me they just look like method calls. E.x. vanilla(100) here for vanilla the price is 100 but how does it actually gets created? I am not getting it at all. Please help :(</p>