title: Regarding a method "cannot be resolved to a type" error
body: <p>I am trying to create null nodes at the bottom of a RBTree and want to instantiate EMPTY as an empty node.</p>
  
  <p>this the line that has the error:</p>
  
  <pre><code>final private Node&lt;E&gt; EMPTY = new Empty();
  </code></pre>
  
  <p>And the empty class:</p>
  
  <pre><code>  private class Empty extends Node&lt;E&gt; {
  
      public Empty() {
          red = false;
      }
      public Node&lt;E&gt; add(E data) {
          count++;
          return new Node&lt;E&gt;(data);
      }
      public Node&lt;E&gt; getNode(E data) {
          return null;
      }
  }
  </code></pre>
  
  <p>I know it has something to do with the constructor but I can't zero in on it. 
  I have tried searching but most everything I come across on this site is related to android programming and/or some other language I'm not familiar with. I've tried the following:</p>
  
  <p>(Node) casting the new Empty(); then realized it was obviously not that.</p>
  
  <p>and working with the class seeing if public would work.</p>
  
  <p>Aside from programming changes i've also tried the solutions offered here:</p>
  
  <p><a href="http://philip.yurchuk.com/software/eclipse-cannot-be-resolved-to-a-type-error/" rel="nofollow">http://philip.yurchuk.com/software/eclipse-cannot-be-resolved-to-a-type-error/</a></p>
  
  <p>But to no success.</p>
  
  <p>Sorry if this question is out of place, and thank you for your time!</p>
  
  <p>complete code:</p>
  
  <pre><code>package data_structures;
  
  
  
  public class RedBlackTree&lt;E extends Comparable&lt;E&gt;&gt; {
  
  private Node&lt;E&gt; root;
  
  private int count = 0;
  
  final private Node&lt;E&gt; EMPTY = new Empty&lt;E&gt;();
  
  public RedBlackTree() {
      root = EMPTY;
  }
  
  public void add(E data) {
      root = root.add(data);
      count++;
      root.red = false;
  }
  
  
  public boolean find(E data) {
      return root.getNode(data) != null;
  }
  
  private class Node&lt;E&gt; {
      public E data;
  
      public boolean red;
      public Node&lt;E&gt;   leftChild;
      public Node&lt;E&gt;   rightChild;
  
      /** Used by Empty */
      protected Node() {
          assert EMPTY == null;
      }
  
      /** Nodes always begin red */
      public Node(E k) {
          data  = k;
          red = true;
          leftChild  = (Node&lt;E&gt;) EMPTY;
          rightChild = (Node&lt;E&gt;) EMPTY;
      }
  
      private boolean isRed() {
          return red;
      }
  
      public int height(){
          return 0; //returns the counts binary left most bit position to determine the height.
      }
  
      public Node&lt;E&gt; add(E newData) {
          if(((Comparable&lt;E&gt;) newData).compareTo(data) == -1) {
              count++;
              leftChild = leftChild.add(newData);
              return leftChild;
          }
          if(((Comparable&lt;E&gt;) newData).compareTo(data) == +1){
              count++;
              rightChild = rightChild.add(newData);
              return rightChild;
          }
          if(((Comparable&lt;E&gt;) newData).compareTo(data) == 0){
              return this;
          }
  
          if (leftChild.isRed() &amp;&amp; leftChild.leftChild.isRed()) {
              return balance(leftChild.leftChild, leftChild, this, 
                             leftChild.leftChild.rightChild, leftChild.rightChild);     
  
          } else if (leftChild.isRed() &amp;&amp; leftChild.rightChild.isRed()) {
              return balance(leftChild, leftChild.rightChild, this, 
                             leftChild.rightChild.leftChild, leftChild.rightChild.rightChild); 
  
          } else if (rightChild.isRed() &amp;&amp; rightChild.leftChild.isRed()) {
              return balance(this, rightChild.leftChild, rightChild,     
                             rightChild.leftChild.leftChild, rightChild.leftChild.rightChild); 
  
          } else if (rightChild.isRed() &amp;&amp; rightChild.rightChild.isRed()) {
              return balance(this, rightChild, rightChild.rightChild,          
                             rightChild.leftChild, rightChild.rightChild.leftChild);     
          }
  
          return this;
      }
  
  
      /** Returns the node for this key, or null. */
      public Node&lt;E&gt; getNode(E newData) {
          if(((Comparable&lt;E&gt;) newData).compareTo(data) == -1){
              return leftChild.getNode(newData);  
          }
          if(((Comparable&lt;E&gt;) newData).compareTo(data) == +1){
              return rightChild.getNode(newData);
          }
          else{
              return this;
          }
      }
  private class Empty&lt;E&gt; extends Node&lt;E&gt; {
  
      public Empty() {
          red = false;
      }
      public Node&lt;E&gt; add(E data) {
          count++;
          return new Node&lt;E&gt;(data);
      }
      public Node&lt;E&gt; getNode(E data) {
          return null;
      }
  }
  
  private Node&lt;E&gt; balance(Node&lt;E&gt; a, Node&lt;E&gt; b, Node&lt;E&gt; c, Node&lt;E&gt; d, Node&lt;E&gt; e) {
  
      a.rightChild = d;
      b.leftChild  = a;
      b.rightChild = c;
      c.leftChild  = e;
      a.red = false;
      b.red = true;
      c.red = false;
      return b;
  }
  
  
  }
  </code></pre>
  
  <p>}</p>