title: Generic RedBlack Driver
body: <p>I'm Trying to insert data threw my driver but it is nothing is working I keep getting my inset highlighted red and telling me that it is not the correct data type.The main problem is I don't understand how to set a generic type Node.Thank you for your help.<br><br>
  Driver(I've been trying diffrent things no progrees):</p>
  
  <pre><code>public class Driver {
      public static &lt;E&gt; void main(String[] args){
            RedBlack&lt;Integer&gt; rb = new RedBlack&lt;Integer&gt;( );
            Node&lt;Integer&gt; item=32;
            rb.insert(item);
         }//close main
  }//close driver
  </code></pre>
  
  <p><br><br>
  REDBLACK CODE:</p>
  
  <pre><code>import java.util.NoSuchElementException;
  public class RedBlack&lt;E extends Comparable&lt;? super E&gt;&gt;{
  ////////////////////////////////SETUP//////////////////////////////////////////   
     private final static int Red=0;             
     private final static int Black=1;
     private Node&lt;E&gt; nil;
     private Node&lt;E&gt; root;
  
     public RedBlack() {
        nil=new Node&lt;E&gt;(null);
        nil.left=nil.right=nil;
        root=new Node&lt;E&gt;(null);
        root.left=root.right=nil;
     }
  
  
     static class Node&lt;E&gt;{
        Node(E theData){
           this(theData,null,null);
        }
  
        Node(E theData,Node&lt;E&gt; lt,Node&lt;E&gt; rt){
              data=theData;
              left=lt;
              right=rt;
              color=RedBlack.Black;
        }
  
        E data;              // The data in the Node
        Node&lt;E&gt; left;        // Left child
        Node&lt;E&gt; right;       // Right child
        Node&lt;E&gt; parent;      // Above Node 
        int color=Black;     // Color of Node
     }
  ////////////////////////////////INSERT////////////////////////////////
     public void insert(Node&lt;E&gt; item) {
        if(item==null) {
           throw new NoSuchElementException("Inset was null");
        }//close if
        Node&lt;E&gt; temp=root;
        if(root==nil) {
           root= item;
           item.color=Black;
           item.parent=nil;
        }//close if
        else {
           item.color=Red;
           while(item!=root) {
              if(compare(item.data,temp.data)&lt;0) {
                 if(temp.right==nil) {
                    temp.right=item;
                    item.parent=temp;
                    break;
                 }//close if
                 else {
                    temp=temp.right;
                 }//close else
              }//close if
              else if(compare(item.data,temp.data)&gt;0){
                 if(temp.left==nil) {
                    temp.left=item;
                    item.parent=temp;
                    break;
                 }//close if
                 else {
                    temp=temp.left;
                 }//close else
              }//close else if
           }//close while
           adjustment(item);
        }//close else
     }//close insert
  
     private void adjustment(Node&lt;E&gt; item) {
        while(item.parent.color==Red) {
           Node&lt;E&gt; uncle;
           if(item.parent==item.parent.parent.left) {
              uncle=item.parent.parent.right;
              if(uncle.color==Red &amp;&amp; uncle!=nil) {   //the uncle needs to exist and and be red to recolored
                 item.parent.color=Black;
                 item.parent.parent.color=Red;
                 uncle.color=Black;
                 continue;
              }//close if
              if(item==item.parent.right) {
                 item=item.parent;
                 lR(item);
              }//close if
              item.parent.color=Black;
              item.parent.parent.color=Red;
              rR(item.parent.parent);
           }//close if
           else {
              uncle=item.parent.parent.left;
              if(uncle.color==Red&amp;&amp;uncle!=nil) {
                 item.parent.color=Black;
                 item.parent.parent.color=Red;
                 uncle.color=Black;
                 continue;
              }//close if
              if(item==item.parent.left) {
                 item=item.parent;
                 rR(item);
              }//close if
              item.parent.color=Black;
              item.parent.parent.color=Red;
              lR(item.parent.parent);
           }//close else
        }//close while
        root.color=Black;
     }//close adjustment
  
     private int compare(E item,E x) {
        if(x==root) {
           return 1;   //same as root will be placed on the right
        }//close if
        else return item.compareTo(x);
     }//close compare
  ////////////////////////////////ROTATE////////////////////////////////
     private void rR(Node&lt;E&gt; node) {
        if(node.parent!=nil) {
           if(node==node.parent.left) {
              node.parent.left=node.left;
           }//close if
           else {
              node.parent.right=node.left;
           }//close else
           node.left.parent=node.parent;
           node.parent=node.left;
           if(node.left.right!=nil) {
              node.left.right.parent=node;
           }//close if
           Node&lt;E&gt; left=root.left;
           root.left=root.left.right;
           left.right.parent=nil;
           root=left;
        }//close if
     }//close rR
     private void lR(Node&lt;E&gt; node) {
        if(node.parent!=nil) {
          if(node==node.parent.left) {
             node.parent.left=node.right;
          }//close if
          else {
             node.parent.right=node.right;
          }//close else
          node.right.parent=node.parent;
          node.parent=node.parent;
          if(node.right.left!=nil) {
             node.right.left.parent=node;
          }//close if
          node.right=node.right.left;
          node.parent.left=node;
        }//close if
        else {
           Node&lt;E&gt; right=root.right;
           root.right=right.left;
           right.left.parent=root;
           root.parent=right;
           right.left=root;
           right.parent=nil;
           root=right;
        }//close else
     }//close lR      
  ////////////////////////////////DELETE////////////////////////////////  
     public void delete(Node&lt;E&gt; node) {
        if((node=find(node,root))==null) {
           System.out.println("Node does not exist");
           return;
        }
        Node&lt;E&gt; node2;
        Node&lt;E&gt; temp=node;
        int tempColor=node.color;
  
        if(node.left==nil) {
           node2=node.right;
           switchNodes(node,node.right);
        }
        else if(node.right==nil) {
           node2=node.left;
           switchNodes(node,node.left);
        }
        else {
           temp=subTree(node.right);
           tempColor=temp.color;
           node2=temp.right;
           if(temp.parent==node) {
              node2.parent=temp;
           }
           else {
              switchNodes(temp,temp.right);
              temp.right=node.right;
              temp.right.parent=temp;
           }
           switchNodes(node,temp);
           temp.left=node.left;
           temp.left.parent=temp;
           temp.color=node.color;
        }
        if(tempColor==Black) {
           deleteAdjustment(node2);
        }
     }//close delete
  
     public void switchNodes(Node&lt;E&gt; node,Node&lt;E&gt; nodeOther) {
        if(node.parent==nil) {
           root=nodeOther;
        }
        else if(node==node.parent.left) {
           nodeOther.parent.left=nodeOther;
        }
        else {
           node.parent.right=nodeOther;
        }
        nodeOther.parent=node.parent;
     }
  
     public Node&lt;E&gt; subTree(Node&lt;E&gt; subRoot) {
        while(subRoot!=nil) {
           subRoot=subRoot.left;
        }
        return subRoot;
     }
  
     public void deleteAdjustment(Node&lt;E&gt; node) {
        while(node!=root &amp;&amp; node.color==Black) {
           if(node==node.parent.left) {
              Node&lt;E&gt; brother=node.parent.right;
              if(brother.color==Red) {
                 brother.color=Black;
                 node.parent.color=Red;
                 lR(node.parent);
                 brother=node.parent.right;
              }//close if
              if(brother.left.color==Black &amp;&amp; brother.right.color==Black) {
                 brother.color=Red;
                 node=node.parent;
                 continue;
              }//close if
              else if(brother.right.color==Black) {
                 brother.left.color=Black;
                 brother.color=Red;
                 rR(brother);
                 brother=node.parent.right;
              }//close else if
              if(brother.right.color==Red) {
                 brother.color=node.parent.color;
                 node.parent.color=Black;
                 brother.right.color=Black;
                 lR(node.parent);
                 node=root;
              }//close if
           }//close if
           else {
              Node&lt;E&gt; brother=node.parent.left;
              if(brother.color==Red) {
                 brother.color=Black;
                 node.parent.color=Red;
                 rR(node.parent);
                 brother=node.parent.left;
              }//close if
              if(brother.right.color==Black&amp;&amp;brother.left.color==Black) {
                 brother.color=Red;
                 node=node.parent;
                 continue;
              }//close if
              else if(brother.left.color==Black) {
                 brother.right.color=Black;
                 brother.color=Red;
                 lR(brother);
                 brother=node.parent.left;
              }//close else if
              if(brother.left.color==Red) {
                 brother.color=node.parent.color;
                 node.parent.color=Black;
                 brother.left.color=Black;
                 rR(node.parent);
                 node=root;
              }//close if
           }//close else
        }//close while
        node.color=Black;
     }//close deleteAdjustment
  ////////////////////////////////FIND////////////////////////////////
  
     public Node&lt;E&gt; find(Node&lt;E&gt; item) {
        if(item==null) {
           throw new NoSuchElementException("Item was null.");
        }//close if
        return find(item,root);
     }//close find
  
     private Node&lt;E&gt; find(Node&lt;E&gt; findNode,Node&lt;E&gt; node) {
        if(root==nil) {
           return null;
        }//close if
        if(compare(findNode.data,node.data)&lt;0) {
           if (node.right != nil) {
              return find(findNode,node.right);
           }
        }
        else if(compare(findNode.data,node.data)&gt;0) {
           if (node.left != nil) {
              return find(findNode,node.left);
           }//close if
        }//close if
        else if(findNode.data==node.data) {
           return node;
        }
        return null;
     }
  
  ////////////////////////////////Print////////////////////////////////
  
     public void printInOrder() {
        if(root==nil) {
           return;
        }//close if
        System.out.print("Key: "+root.data+"-Black");
        printTree(root);
     }//close printInOrder
  
     public void printTree(Node&lt;E&gt; node) {
        if(node==nil) {
           return;
        }//close if
        printTree(node.left);
        if(node.color==Black) {
           System.out.print("Key: "+node.data+"-Black");
        }//close if
        else {
           System.out.print("Key: "+node.data+"-Red");
        }//close else
        printTree(node.right);
     }//close printTree
  }//close class
  </code></pre>