title: comparable used as structure in a binary tree
body: <p>I have a binary tree in Java that works nicely. But I want to enhance the data content in the node. Currently I can add values on it doing such as:</p>
  
  <pre><code>for( int i = 1; i &lt;=10; i++ )
      t.insert( new Integer( i ) );
  </code></pre>
  
  <p>Which will add the item like this:</p>
  
  <pre><code>public void insert( Comparable item ) {
      current = parent = grand = header;
      nullNode.element = item;
      ...
  }
  </code></pre>
  
  <p>Here is the format of the tree:</p>
  
  <pre><code>private static class RedBlackNode {
      // Constructors
      RedBlackNode( Comparable theElement ) {
          this( theElement, null, null );
      }
  
      RedBlackNode( Comparable theElement, RedBlackNode lt, RedBlackNode rt ) {
          element  = theElement;
          left     = lt;
          right    = rt;
          color    = RedBlackTree.BLACK;
      }
  
      Comparable   element;    // The data in the node
      RedBlackNode left;       // Left child
      RedBlackNode right;      // Right child
      int          color;      // Color
  }
  </code></pre>
  
  <p>For showing the tree, I do like that:</p>
  
  <pre><code>private void printTree( RedBlackNode t ) {
      if( t != nullNode ) {
          printTree( t.left );
          System.out.println(t.element);
          printTree( t.right );
      }
  }
  </code></pre>
  
  <p>While when programming in many other languages, the element would be declared as a <a href="https://stackoverflow.com/questions/36701/struct-like-objects-in-java">struct</a>, for this <a href="http://www.sanfoundry.com/java-program-implement-red-black-tree/" rel="nofollow noreferrer">sample code</a> in Java it is declared as <a href="http://www.onjava.com/pub/a/onjava/2003/03/12/java_comp.html" rel="nofollow noreferrer">Comparable</a>, and currently is only taking one element as integer. My question is, how can I use it similarly as a struct, in order to be able to also manipulate it such as doing in this pseudo code:</p>
  
  <pre><code>System.out.println(t.element.valueInt);
  System.out.println(t.element.firstNameString);
  System.out.println(t.element.lastNameString);
  </code></pre>
  
  <p>I have tried different syntax combinations based on some previous <a href="https://stackoverflow.com/questions/3718383/java-class-implements-comparable">posts</a>, but none has worked so far. </p>
  
  <p>For the current code version with added comments, check <a href="https://gist.github.com/emmayazzie" rel="nofollow noreferrer">Gist</a>.</p>
  
  <p>All suggestions are deeply appreciated.</p>