| Author |
question about the generic methods : ExamLab final test
|
Prasad Kharkar
Ranch Hand
Joined: Mar 07, 2010
Posts: 438
|
|
I am unable to interpret the meaning of the following code
I am not able to understand what the statement
means
what I know is this
1. This is generic method
2. that can be passed any instantiation which can be <T extends E>
3. Its return type is A
but I am not able to understand what <? super T> means after A
please help me
|
SCJP 6 [86%] June 30th, 2010
If you find any post useful, click the "plus one" sign on the right
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
There is a generic type declared in the GenClass which is E. E can be any class which extends A (or A itself). In the method declaration you declare another type T which extends E (E in itself is A or its subclass). The parameter the method gets is A<? super T>. This means that the method will receive an instance of A which has a type of T or a super class of T. To make this simpler to understand, lets replace A with a class from the Java API
The method parameter and return type are now easier to understand (I hope)...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Prasad Kharkar
Ranch Hand
Joined: Mar 07, 2010
Posts: 438
|
|
of course they are easier now
after this nice explanation
thanks a lot
|
 |
 |
|
|
subject: question about the generic methods : ExamLab final test
|
|
|