This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
<? super Object> means you can have Object type or its Super Class type at type where you are mentioning the type.It means whatever the Type you are mentioning in Generic it should be Object or its Super Object T should be Super of Object mens Super Classtype not SubClass type.But this method will allow you to add thngs to The collection that type.But The method with following Declaration gives compilation error when you try to add the Objects.<? extends Object>.It menas the type can be either Object or its SubClass.Just remeber its Declaration for type only.
When you gave decleration as <? super Object> you need to specify the type in method call.When you specify the the type then you can add only those type objects or the Objects which satisfy IS-A.
I think this will answer your Question.
Please correct me if i am wrong.
with Regards,<br />VidyaVikas Yalamanchili SCJP 5.0
The way that I like to look at this ( <? super ClassName> ) is like this
if you declare a reference...
List<? super ClassName> list1;
Then that reference can hold a List of ClassName or a List of anything higher in ClassName's class hierarchy.
THAT guarantees that whatever List you assign to list1... it WILL be able to accept a ClassName element.
If list1 will accept a ClassName type, then it will accept a subclass of ClassName type element.
Thus, a List<? super Number> reference will hold a Number, an Integer, a Float, a Double, or any other of the wrapper classes.
Now, if you have a reference typed
List<? extends Number> list2;
then list two will be able to accept a List of Number or anything that is a subclass of Number. That means it will accept List<Number>, List<Integer>, List<Float> or any List of any other wrapper class. With that being true at run-time, the JVM can not be sure what type is currently referenced. All of the "type" information will have been wiped (type erasure). So the compiler, in order to guarantee the type safety of the List, simply will not allow anything to be put on that list using that reference. At run-time, yes, list2 COULD be a reference to List<Number>... but it COULD be a List<Float>. This rule keeps us from adding a short to the List<Float>.
SCJP - 86% - June 11, 2009