title: Error java.lang.Integer is not within bounds of type-variable T; BinarySearchTree
body: <p>I want to create a simple Binary Search Tree which uses generics to specify the data type.
  However, when I want to create a new tree of Integers, I get the following error:</p>
  
  <blockquote>
    <p>type argument java.lang.Integer is not within bounds of type-variable T</p>
  </blockquote>
  
  <p>I tried other data types which are clearly extending <code>Comparable</code>, so why is this not working?</p>
  
  <p>Here is my code:</p>
  
  <p>Interface:</p>
  
  <pre><code>public interface Comparable&lt;T&gt;
  {
      int compareTo( T t );
  }
  </code></pre>
  
  <p>BinarySearchTree:</p>
  
  <pre><code>public class BinarySearchTree&lt;T extends Comparable&lt;T&gt;&gt;
  {
  private T content;
  private BinarySearchTree&lt;T&gt; leftChild, rightChild;
  
  public BinarySearchTree()
  {
      content = null;
      leftChild = null;
      rightChild = null;
  }
  
  public T getContent()     
  {
      if(!isEmpty())
      {
          return content;
      }
      else
      {
          throw new RuntimeException();
      }
  }
  
  public boolean isEmpty()
  {
      return content == null;
  }
  
  public boolean isLeaf()
  {
      return !isEmpty() &amp;&amp; leftChild.isEmpty() &amp;&amp; rightChild.isEmpty();
  }
  
  public void add(T t)
  {
      if(isEmpty())
      {
          content = t;
          leftChild = new BinarySearchTree&lt;T&gt;();
          rightChild = new BinarySearchTree&lt;T&gt;();
      }
      else
      {
          if(content.compareTo(t) &gt; 0)
          {
              leftChild.add(t);
          }
          if(content.compareTo(t) &lt; 0)
          {
              rightChild.add(t);
          }
      }
  } 
  
  public int size()
  {
      if(isEmpty())
      {
          return 0;
      }
      else
      {
          return 1 + leftChild.size() + rightChild.size();
      }
  }
  
  public boolean contains(T t)
  {
      if(isEmpty())
      {
          return false;
      }
      else
      {
          if(content.compareTo(t) &gt; 0)
              leftChild.contains(t);
          else if(content.compareTo(t) &lt; 0)
              rightChild.contains(t);
          return true;
      }
  }
  
  public void show()
  {
      if(!isEmpty())
      {
          leftChild.show();
          System.out.println(content);
          rightChild.show();
      }
  }
  
  }
  </code></pre>
  
  <p>Main:</p>
  
  <pre><code>public class main
  {
  
  public static void main(String[] args)
  {
      test();
  }
  
  public static void test()
  {
      BinarySearchTree&lt;Integer&gt; tree = new BinarySearchTree&lt;&gt;();
      tree.add("5");
      tree.add("10");
      tree.add("3");
      tree.add("1");
      tree.show();
  }
  }
  </code></pre>
  
  <p>The error comes with this line: <code>BinarySearchTree&lt;Integer&gt; tree = new BinarySearchTree&lt;&gt;();</code></p>