title: enum to create and contain objects java
body: <p>I have a class called Planet that creates Planet objects with some attributes. Can I have an enum (not used to them yet) that stores and creates the planets? For example something like:</p>
  
  <pre><code>public enum planetEnum{
      earth (250, 0, 100, "blue"),
      mars (360, 0, 80, "red");
  
      planetEnum(double distance, double angle, double diameter, String col){
          new Planet(distance, angle, diameter, col);
      }
  }
  </code></pre>
  
  <p>Hoping that in the end I can refer to mars and earth as objects, i.e. : earth.getDistance()</p>
  
  <p>I hope its clear :) 
  Thanks in advance!</p>
  
  <p><strong>Edit</strong>: Thanks for your responses. I've found and read already the oracle tut on enums but I couldn't find what I was actually looking for. Because it's a task to learn the basics of inheritance, I need to keep the Planet class separate and to create Planet objects, so I cant actually put the constructor in the enum. Is there a way to refer to the Planet class and create from it, from inside of the enum?</p>
  
  <p>Thanks again!</p>