title: Why don't you get a compiler error when assign raw types to generic types?
body: <p>I have been looking at OJCPA code snippets and I am confused why the compiler does not throw an error at the following code.</p>
  
  <pre><code>List l = new ArrayList();
  l.add("a");
  l.add("b");
  l.add(1);
  
  List&lt;String&gt; strList = new ArrayList&lt;&gt;();
  strList = l; //#1 - Why does the assignment compile?
  
  for(String s: strList) {
        System.out.println(s); //#2 - It makes sense that it then throws a ClassCastException
  }
  </code></pre>
  
  <p>I thought that the compiler would see List l as a raw type and because generics are invariant it would produce a compiler error, as it is not of type List&lt; String >.</p>
  
  <p>Thanks for you help.</p>