title: The method mergeList(List<Integer>) in the type Utility<Integer> is not applicable for the arguments (List<Number>)
body: <p>I have this assignment where I'm only allowed to change the signature of the methods. I have a class utility and a test class. Th issue I'm having is that i keep getting argument errors. Here is the Utility Class</p>
  <pre><code>public class Utility &lt;T extends Comparable&lt;T&gt;&gt; {  //Change this line to create a parameterized class
      
      // Insert your code here
      public ArrayList&lt;T&gt; list;
      
      public Utility() {
          list = new ArrayList&lt;T&gt;();
      }
      
      public Utility (List&lt;T&gt; list) { 
          this.list = (ArrayList&lt;T&gt;) new ArrayList&lt;&gt;(list);
      }
  
      public void mergeList(List&lt;T&gt; list) { //This is the method that the error refers to
          for (T obj: this.list)
              list.add(obj);
      }
  }
  </code></pre>
  <p>This is the test that keeps giving me errors</p>
  <pre><code>void testMergeList2() {
          List&lt;Integer&gt; myList = new ArrayList&lt;Integer&gt;(); 
          myList.add(0); 
          myList.add(1); 
          myList.add(2); 
          myList.add(3); 
          Utility&lt;Integer&gt; ut = new Utility&lt;Integer&gt;(myList); 
  
          List&lt;Number&gt; myList2 = new ArrayList&lt;Number&gt;(); 
          myList2.add(0); 
          myList2.add(1); 
          myList2.add(2); 
          myList2.add(5); 
          ut.mergeList(myList2);      //This is where I get the error 
          boolean actual = true;
          for (int i= 0; i &lt; 4; i++) {
              if ((Integer) myList2.get(i) != i || (Integer)myList2.get(i+4)!= i) {
                  actual = false; 
                  break; 
              }
          }
  
          boolean expected = false; 
          assertEquals(expected, actual, &quot;mergeList Failed! &quot; + expected + &quot; expected but &quot;+ actual + &quot; is given&quot;);
          
          
      }
  </code></pre>
  <p>I tried changing T for something else but then the compiler tells me to cast T which I'm not allowed to do since I can't change the body of the method.</p>