title: Java - Can you access an Enum declared in Subclass from Super class?
body: <p>I was hoping to declare in Enum type in a subclass and then access it from the super class.  This is what I came up with, but it does  not work:</p>
  
  <pre><code>class Subclass {
   enum Pets {
    CAT,
    DOG;
   }
  
  Class&lt;Pets&gt; getEnumClass() {
      return Pets.class;
   }
  }
  
  class Superclass  {
      // This generates a warning: 
  abstract Class&lt;? extends Enum&gt; getEnumClass(); 
  void PrintEnumNames() throws InstantiationException, IllegalAccessException {
  Class&lt;? extends Enum&gt; enumClass = getEnumClass();
  
  Enum newEnum = enumClass.newInstance();
   for( Enum iEnum : newEnum.values()) { // newEnum.values() isn't available
      System.out.printf("%s", iEnum.toString());
     }
   }
  }
  </code></pre>