title: Java Generics Error
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/529085/java-how-to-generic-array-creation">Java how to: Generic Array creation</a><br>
    <a href="https://stackoverflow.com/questions/3865946/error-generic-array-creation">Error: Generic Array Creation</a>  </p>
  </blockquote>
  
  
  
  <p>I am getting this error:</p>
  
  <pre><code>Cannot create a generic array of T
  </code></pre>
  
  <p>This is my code (error on line 6):</p>
  
  <pre><code>1    public class HashTable&lt;T&gt; {
  2    
  3        private T[] array;
  4    
  5        HashTable(int initSize) {
  6            this.array = new T[initSize];
  7        }
  8    }
  </code></pre>
  
  <p>I am wondering why this error is appearing and the best solution to fix it. Thanks.</p>
  
  <p>UPDATE:
  <p>
  I adjusted my code so that the array is taking in linked lists instead, but I am getting a new error.
  </p>
  
  <p>Here is my error:</p>
  
  <pre><code>Cannot create a generic array of LinkedList&lt;T&gt;
  </code></pre>
  
  <p>Here is my code (error on line six):</p>
  
  <pre><code>1    public class HashTable&lt;T&gt; {
  2    
  3        private LinkedList&lt;T&gt;[] array;
  4    
  5        HashTable(int initSize) {
  6            this.array = new LinkedList&lt;T&gt;[initSize];
  7        }
  8    }
  </code></pre>
  
  <p>Is this error for the exact same reason? I was just assuming I could create generic linked lists and just store them in the array.</p>