title: Why am I not getting a compile error when passing a list of Integer for a list of String parameter?
body: <pre class="lang-java prettyprint-override"><code>public class Generic&lt;T&gt; {
  
      public static void main(String[] args) {
          Generic g = new Generic();
          List&lt;Integer&gt; integerList = new ArrayList&lt;&gt;();
          integerList.add(42);
          g.f(integerList);
          System.out.println(integerList);
      }
  
      void f(List&lt;String&gt; stringList){
          stringList.add("hello");
      }
  }
  
  </code></pre>
  
  <p>Executing this code will COMPILE and print <code>[42, hello]</code></p>
  
  <p>I'm passing my <code>List&lt;Integer&gt; integerList</code> to a <code>List&lt;String&gt; stringList</code> and the compiler is fine with it. Why? Isn't the compiler suppose to check this sort of things? Line with <code>g.f(integerList);</code> should throw a compile error. It's not.</p>