This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Think about it, what would be the use of <T super B>. If I create a list as Now what can I do with list?? The compiler can't let you add Short or Long objects to list as T might actually evaluate to Integer at runtime. You can only retrieve elements from list to references of type Object as again T is not known. So <T super Integer> will work the same as <? super Integer>...
Simone Aiello wrote:
I asked why I can't use the super in a declaration,
whereas I can use the extends.
Short answer: Because the JLS states that it is not legal.
Longer answer: What purpose would it serve? Since everything inherits from Object, something that must be a type that is super of B, means that it could be type Object. And since everything IS-A Object, it means the container can hold anything. What would the compiler need to type check?