title: Type mismatch error when assigning a variable to an object of the same type
body: <p>I'm working on an Iterator for a linked list class. I am assigning nodes to variables within an inner class and am getting a "Type mismatch" error. Relevant code is below.</p>
  
  <pre><code>public class RegLinkList&lt;T&gt; implements Iterable&lt;T&gt;{
      private Node&lt;T&gt; head;
  public RegLinkList() {
          head = null;
      }   
   public class Node&lt;T&gt; {
     public Node&lt;T&gt; next = null;
     public T data = null;
  
     Node(T data){
          this.data = data;
      }
    }
      public class ListIterator&lt;T&gt; implements Iterator&lt;T&gt;{
      Node&lt;T&gt; current = head;
      Node&lt;T&gt; previous = head;
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>    Type mismatch: cannot convert from 
      RegLinkList&lt;T&gt;.Node&lt;T&gt; to RegLinkList&lt;T&gt;.Node&lt;T&gt;    
  </code></pre>
  
  <p>Edit:
  My current solution is an unchecked cast of </p>
  
  <pre><code>    public class ListIterator&lt;T&gt; implements Iterator&lt;T&gt;{
      Node&lt;T&gt; current = (Node&lt;T&gt;) head;
      Node&lt;T&gt; previous = (Node&lt;T&gt;) head;
  </code></pre>