title: Ljava.lang.Object; cannot be cast to class ClassName
body: <p>I am trying to implement a linked structure using arrays.</p>
  <pre><code>public class LinkedArray &lt;E extends Comparable&lt;E&gt;&gt;{
  private Node&lt;E&gt;[] array;
  private int head;
  private int size = 0; 
  private int capacity;
  
  @SuppressWarnings(&quot;unchecked&quot;)
  public LinkedArray (){
      capacity = 10;
      array= (Node&lt;E&gt;[]) new Object[capacity];
      head = -1;
      size = 0;
  }
  }
  </code></pre>
  <p>It has inner node class</p>
  <pre><code>private static class Node&lt;T&gt;{
      protected T data = null;
      protected int next = -1;
  }
  </code></pre>
  <p>I get the error :</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [LinkedArray$Node; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [LinkedArray$Node; is in unnamed module of loader 'app')
  </code></pre>
  <p>For the line</p>
  <pre><code>array = (Node&lt;E&gt;[]) new Object[capacity];
  </code></pre>
  <p>What is the reason? How can I create a Node array?</p>