title: compareTo(K) in java.lang.Comparable<K> cannot be applied to (java.lang.Comparable)
body: <p>I am trying to define a generic class which can work with any data type with <code>Comparable</code> interface defined. 
      <p>The error message is <code>compareTo(Key) in java.lang.Comparable&lt;Key&gt; cannot be applied to (java.lang.Comparable) on line 22</code></p> I suspect this has to do with my <code>TreeNode</code> class declaration, but I cannot figure out what it is.
   <p><code>Warnings [unchecked] unchecked call to TreeNode(Key) as a member of the raw type findLargestKElementsInTree.TreeNode on line 16</code></p></p>
  
  <pre><code>    class findLargestKElementsInTree&lt;Key extends Comparable&lt;Key&gt;&gt;{
        TreeNode root;
  
        int count=1;
  
        public void insert(Key k)
        {
         this.insert(k,root,root);
  
        }
        private void insert(Key k, TreeNode node,TreeNode parent)
        {
          if(this.root==null)
           root=new TreeNode(k);
          if(node==null)
          {
            node=new TreeNode(k);
            if(parent != null)
            {
             if(k.compareTo(parent.data)&lt;0)
               parent.left=node;
             else
               parent.right=node;
            }
          }
          else
          {
            if(node.data.compareTo(k)&gt;0)
               insert(k,node.left,node);
            else if(node.data.compareTo(k)&lt;0)
               insert(k,node.right,node);
            else
              return;
          }
        }
  
  
  
        public void printK(int k)
        {
          postOrderK(root,k);
        }
        /*
         *       42
         *    40
         * 20    25
         *    10
         *      5
         * 
         * 
         * 
         * */
        public void postOrderK(TreeNode n,int k)
        {
         if(n==null) 
           return;
         if(n.right!=null)
           postOrderK(n.right,k);
         if(count &lt;= k)
         {
           System.out.println(count+" largest number "+n.data);
           count++;
         }
         postOrderK(n.left,k);
  
  
        }
  
         public class TreeNode&lt;Key extends Comparable&lt;Key&gt;&gt;{
           Key data;
           TreeNode left;
           TreeNode right;
           TreeNode(Key d)
           {
             this.data=d;
             this.left=null;
             this.right=null;
           }
         }
  
         public static void main(String[] args)
         {
           findLargestKElementsInTree&lt;Integer&gt; tree=new findLargestKElementsInTree&lt;Integer&gt;();
           tree.insert(20);
           tree.insert(40);
           tree.insert(10);
           tree.insert(5);
           tree.insert(42);
           tree.insert(25);
           tree.printK(7);
  
         }
  
       }
  </code></pre>
  
  <p>I have looked at other questions on stack overflow which seem to be helping out with similar problem, but the solution suggested is to have a generic class, I think I already have that.</p>
  
  <p>Thanks in advance!</p>