title: How to create a class which holds list of any children of a class?
body: <p>Java doubts:</p>
  
  <p>let's say I have a class named A.
  and I have its child classes as A1, A2, A3, etc. as shown below</p>
  
  <p>e.g.</p>
  
  <pre><code>Class A 
  {
  
  }
  
  Class A1 extends A {
  }
  
  Class A2 extends A{}
  Class A3 extends A{}
  
  
  </code></pre>
  
  <p>Now I have another class which is ListA class. 
  this class has an attribute which is basically a list of any children of class A.</p>
  
  <pre><code>Class ListA&lt;T&gt; {
  List&lt;T&gt; listOfChildren;
  
  ListA(int n) {
  //some how instantiate the above list based on the generic type.
  }
  }
  }
  </code></pre>
  
  <p>I have used generic class because I think it is good way to tackle this use case. But any other suggestions will be helpful. </p>