Why is List<String> not a subtype of List<Object>?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2660827/java-generics-covariance">java generics covariance</a>  </p>
</blockquote>



<p>I am trying to make sense of the fact that  <code>List&lt;String&gt;</code> is <strong>not</strong> a subtype of <code>List&lt;Object&gt;</code>. </p>

<p>In effective Java, Josh Bloch notes that although it may seem counter-intuitive,it does make sense. The reason he stated is that you can put any Object in <code>List&lt;Object&gt;</code>, but can only put String in <code>List&lt;String&gt;</code>. I am not sure how this justifies why the String list is not a subtype of Object list. </p>

<p>Maybe I am confused by the term <code>subtype</code>. What I think it means is that when S is a subtype of T, an instance of S is an instance of T. Therefore, for <code>List&lt;String&gt;</code> to be a subtype of <code>List&lt;Object&gt;</code>, Object has to be a super class of String, which it technically is. Any idea where my reasoning went wrong? </p>
