At runtime, how to specify a class so that a function can create an object of that specific class?
<p>I have an interface called Model. It has a method called deserialize()</p>

<pre><code>public interface Model 
{
   public void deserialize(String s);
}
</code></pre>

<p>There are many implementations of the Model interface. </p>

<p>I have a special class called Utilities that works on Model objects (i.e. implementations of the Model interface). </p>

<p>In Utilities, I have a function that takes a specified class, an creates a list of objects of that class.</p>

<pre><code> public static &lt;T extends Model&gt; List&lt;T&gt; getList(StringReader reader, Class &lt;T&gt; theClass)
{
   ...
} 
</code></pre>

<p>I have two classes A and B that both implement Model. In class A, I have the following code - </p>

<pre><code>A
{
  int x;
  int y;
  int z;
  ArrayList&lt;B&gt; listOfBObjects;


public void deserialize(String dataString)
 {
    ...
    ...
    listOfBObjects = Utilities.getList();  &lt;-- here I want to specify "B". How to do that?
 }
}
</code></pre>

<p>How to specify "B" as an argument to the getList() function above?</p>
