title: Casting between an object of generic type "T" and an object of generic type "<T extends Comparable<T>>"
body: <p>I've implemented an ArrayLinearList class on the following way</p>
  
  <pre><code>public class ArrayLinearList&lt;T&gt; implements LinearList&lt;T&gt;, Iterable&lt;T&gt;
  </code></pre>
  
  <p>which contains the class member </p>
  
  <pre><code>protected T[] element
  </code></pre>
  
  <p>In order to extend the functionality of the class I create a new class that inherits from the first one </p>
  
  <pre><code>class SuperList&lt;T extends Comparable&lt;T&gt;&gt; extends ArrayLinearList&lt;T&gt;
  </code></pre>
  
  <p>Here I ensure that the type T implements the Comparable interface (this cannot be changed). </p>
  
  <p>In the SuperList class I have the following method</p>
  
  <pre><code>public void replace( int pedro, T maria ){
     element[ pedro ] = maria;
  </code></pre>
  
  <p>}</p>
  
  <p>The line of the method generate the following error</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Comparable;
  </code></pre>
  
  <p>But if I declare the class on the following way I don't have this problem anymore (but in this way I'm no longer able to compare class objects)</p>
  
  <pre><code>class SuperList&lt;T&gt; extends ArrayLinearList&lt;T&gt;{
  </code></pre>
  
  <p>I would appreciate any help to solve this issue. I'm not allowed to modify the class \ [ ArrayLinearList, just the class SuperList.</p>
  
  <p>Thanks in advance.</p>