title: How do I instantiate an instance of a generic method parameter in Java?
body: <p>Consider the following code:</p>
  
  <pre><code>// ...
  public class BaseClass
  {
      public BaseClass (int theParam)
      {
          // ...whatever...
      }
  }
  public class DerivedType
  {
      // ...Content does not matter...    
  }
  
  
  // ...elsewhere:
  
  public &lt;ElemType extends BaseClass&gt; boolean doIt (ArrayList&lt;ElemType&gt; target)
  {
      ElemType newElem=new ElemType (5) ; // "Cannot instantiate this type"
  
      // ...other code does not matter...
  
      return true ;
  }
  
  // ..
  </code></pre>
  
  <p>How can I create an instance of type <code>ElemType</code> in <code>doIt</code>?</p>
  
  <p>The construct shown yields the error indicated.</p>
  
  <p><code>ElemType.newInstance</code> does not exist, which surprises me.</p>
  
  <p>I've read practically all FAQs, answers and googleable material, but I cannot find anything helpful.</p>
  
  <p>EDIT:
  Yes I know reflection has its downsides, and is not the ultimate solution, for numerous reasons. The question is not "should I do it", but "how would I do it".</p>