Regarding an example illustrating the usage of generic class syntax
<p>In thinking in Java, page 566 gives the following example. </p>

<pre><code>class CountedInteger {
  private static long counter;
  private final long id = counter++;
  public String toString() { return Long.toString(id); }
}
public class FilledList&lt;T&gt; {
  private Class&lt;T&gt; type;

  public FilledList(Class&lt;T&gt; type) { this.type = type; }

  public List&lt;T&gt; create(int nElements) {
    List&lt;T&gt; result = new ArrayList&lt;T&gt;();
    try {
       for(int i = 0; i &lt; nElements; i++)
       result.add(type.newInstance());
    } catch(Exception e) {
      throw new RuntimeException(e);
    }
    return result;
  }

   public static void main(String[] args) {
     FilledList&lt;CountedInteger&gt; fl = new FilledList&lt;CountedInteger&gt;(CountedInteger.class);
     System.out.println(fl.create(15));
   }
} 
</code></pre>

<p>I have three questions with respect to this example.</p>

<p>1) What is the usage of private Class type? Why is it private?</p>

<p>2) Why do the following, in particular " this.type = type;"</p>

<pre><code>public FilledList(Class&lt;T&gt; type) { this.type = type; }
</code></pre>

<p>3) The author claims:</p>

<blockquote>
  <p>Notice that this class must assume that any type that it works with
  has a default constructor (one without arguments), and you’ll get an
  exception if that isn’t the case.</p>
</blockquote>

<p>I can not figure out how this statement was reflected in the above example. Thanks.</p>
