title: Is there a way to create instances of child class in parent class?
body: <p>I'm not sure if I'm explaining it correctly so I'll explain through an example.</p>
  
  <pre><code>public class ParentClass{
      public static ArrayList&lt;ParentClass&gt; generateInstances(int count){
          ArrayList&lt;ParentClass&gt; array = new ArrayList&lt;ParentClass&gt;();
          for(int i = 0; i &lt; count; i++)
              array.add(new this.getClass());
          return array;
      }
  }
  
  public class ChildClass1 extends ParentClass{
  
  }    
  
  
  public class ChildClass1 extends ParentClass{
  
  }
  
  public class ChildClass2 extends ParentClass{
  
  }
  
  public class ChildClass3 extends ParentClass{
  
  }
  </code></pre>
  
  <p>So I have a class that has a lot of child classes. Somewhere else I would like to be able to create a set amount of each of the child classes. So I thought I'd make a function that would return just that. Is there a way for me to not have to implement <code>generateInstances()</code> in each of them, only in <code>ParentClass</code>.</p>