title: Generics..? Super T
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1910892/what-is-the-difference-between-super-and-extends-in-java-generics">what is the difference between ‘super’ and ‘extends’ in Java Generics</a>  </p>
  </blockquote>
  
  
  
  <p>A)  </p>
  
  <pre><code>List&lt;? super Shape&gt; shapeSuper = new ArrayList&lt;Shape&gt;();
  
  shapeSuper.add(new Square());       //extends from SHAP  
  shapeSuper.add(new DoubleSquare()); //extends from SQ  
  shapeSuper.add(new TripleSquare()); //extends from DS  
  shapeSuper.add(new Rectangle());    //extends from SHAP  
  shapeSuper.add(new Circle());       //extends from SHAP  
  
  for (Object object : shapeSuper) { ... }
  </code></pre>
  
  <p>Why must the iteration be of Objects when I can add only Shape and its
  derivatives?</p>
  
  <p>B)</p>
  
  <pre><code>List&lt;? super Shape&gt; shapeSuper = new ArrayList&lt;Object&gt;();  
  
  shapeSuper.add(new Object()); //compilation error  
  </code></pre>
  
  <p>Why does the above line produce a compilation error?   </p>