title: Method with generics don't accept class as argument
body: <p>I'm studying java in my class and I need to sort a doubly linked list, and I got the code, it works, but when I use the code in my environment, I receive an error:</p>
  
  <blockquote>
    <p>The method sort(DoubleLinkedList&lt;T>) in the type DoubleLinkedListSort
    is not applicable for the arguments (DoubleLinkedList&lt;Item>)</p>
  </blockquote>
  
  <p>This is the class that I got here: <a href="https://stackoverflow.com/a/2938529/4611395">https://stackoverflow.com/a/2938529/4611395</a></p>
  
  <p>Just changed the List class to my DoubleLinkedList class.
  So, I'm using this way.</p>
  
  <pre><code>DoubleLinkedList&lt;Item&gt; it = new DoubleLinkedList&lt;Item&gt;();
  
  it = DoubleLinkedListSort.sort( it );
  </code></pre>
  
  <p>If I change the generic T to my class Item, it works with no problem.
  Anyone know why this problem? I learned that it should be working.</p>
  
  <p>Thank you.</p>
  
  <p>Edit:</p>
  
  <p>This is my <strong>DoubleLinkedListSort</strong> that I edited.</p>
  
  <pre><code>package list;
  
  import list.DoubleLinkedList;
  
  public class DoubleLinkedListSort
  {
      private static int depth = 0;
  
      public static &lt;T extends Comparable&lt;T&gt;&gt; DoubleLinkedList&lt;T&gt; sort( DoubleLinkedList&lt;T&gt; Ts )
      {
          depth++;
          String tabs = getTabs();
  
          System.out.println( tabs + "Sorting: " + Ts );
  
          if( Ts.listSize() &lt;= 1 ) 
          {
              depth--;
              return Ts;
          }
  
          DoubleLinkedList&lt;T&gt; left = new DoubleLinkedList&lt;T&gt;();
          DoubleLinkedList&lt;T&gt; right = new DoubleLinkedList&lt;T&gt;();
          DoubleLinkedList&lt;T&gt; result = new DoubleLinkedList&lt;T&gt;();
  
          int middle = Ts.listSize() / 2;
          int added = 0;
  
          for( int i = 0; i &lt; Ts.listSize(); i++ )
          {
              try
              {
                  if( added++ &lt; middle )
                      left.insertFirst( Ts.getElementAtPosition( i ) );
                  else
                      right.insertFirst( Ts.getElementAtPosition( i ) );
              }
              catch( DoubleLinkedListException d )
              {
  
              }
          }
  
          left = sort( left );
          right = sort( right );
          result = merge( left, right );
  
          System.out.println( tabs + "Sorted to: " + result );
  
          depth--;
          return result;
      }
  
      private static &lt;T extends Comparable&lt;T&gt;&gt; DoubleLinkedList&lt;T&gt; merge( DoubleLinkedList&lt;T&gt; left, DoubleLinkedList&lt;T&gt; right ) 
      {
          String tabs = getTabs();
          System.out.println( tabs + "Merging: " + left + " &amp; " + right );
  
          DoubleLinkedList&lt;T&gt; result = new DoubleLinkedList&lt;T&gt;();
  
          while( left.listSize() &gt; 0 &amp;&amp; right.listSize() &gt; 0 )
          {
              try
              {
                  if( left.getElementAtPosition( 0 ).compareTo( right.getElementAtPosition( 0 ) ) &lt; 0 )
                  {
                      result.insertLast( left.getElementAtPosition( 0 ) );
  
                      left.deleteElementAtPosition( 0 );
                  }
                  else
                  {
                      result.insertLast( right.getElementAtPosition( 0 ) );
  
                      right.deleteElementAtPosition( 0 );
                  }
              }
              catch( DoubleLinkedListException d )
              {
  
              }
          }
  
          try
          {
              if( left.listSize() &gt; 0 )
              {
                  for( int i = 0; i &lt; left.listSize(); i++ )
                  {
                      result.insertLast( left.getElementAtPosition( i ) );
                  }
              }
              else
              {
                  for( int i = 0; i &lt; right.listSize(); i++ )
                  {
                      result.insertLast( right.getElementAtPosition( i ) );
                  }
              }
          }
          catch( DoubleLinkedListException d )
          {
  
          }
  
          return result;
      }
  
      private static String getTabs()
      {
          StringBuffer sb = new StringBuffer( "" );
  
          for( int i = 0; i &lt; depth; i++ )
              sb.append( '\t' );
  
          return sb.toString();
      }
  }
  </code></pre>
  
  <p>Edit 2:</p>
  
  <p>As <a href="https://stackoverflow.com/questions/30061046/method-with-generics-dont-accept-class-as-argument#comment48237188_30061046">Method with generics don&#39;t accept class as argument</a> and <a href="https://stackoverflow.com/a/30061121/4611395">https://stackoverflow.com/a/30061121/4611395</a> commented, it was just implement Comparable and it worked.</p>
  
  <pre><code>public class Item implements Comparable&lt;Item&gt;
  .
  .
  .
  @Override
  public int compareTo( Item it )
  {
      return this.name.compareTo( it.name );
  }
  </code></pre>
  
  <p>Thank you guys for the help.</p>