title: Java: create instance of variable class
body: <p>I have interface <code>Cat</code> that is implemented by classes <code>LolCat</code> and <code>FatCat</code>. My program needs to remember which type of <code>Cat</code> user wanted melt with next. I cannot instantiate the proper <code>Cat</code> yet, so I need to remember the class. How do I do this?</p>
  
  <hr>
  
  <p>I tried:</p>
  
  <pre class="lang-java prettyprint-override"><code>Class nextCatClass = FatCat.class;
  </code></pre>
  
  <p>But now I don't know how to instantiate it using a variable. <code>new nextCatClass()</code> is not a valid syntax. I also tried</p>
  
  <pre class="lang-java prettyprint-override"><code>Class&lt;Cat&gt; nextCatClass = FatCat.class;
  </code></pre>
  
  <p>but now I get an "incompatible types" error.</p>
  
  <hr>
  
  <p>Risking to annoy the heck out of Java users, here's what I'd do in Python:</p>
  
  <pre class="lang-py prettyprint-override"><code>next_cat_class = FatCat
  ...
  instance = next_cat_class()
  </code></pre>