SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
SCJP6.0,My blog Ranchers from Delhi
Malatesh Karabisti wrote:From K & B Book
public void addAnimal(List<? super Dog> animals)
is essentially, "Hey compiler, please accept any List with a generic type that is of type Dog, or a supertype of Dog.
Nothing lower in the inheritance tree can come in, but anything higher than Dog is OK."
I think my source of confusion is these words still these words not very clear to me ?
SCJP6.0,My blog Ranchers from Delhi
SCJP6.0,My blog Ranchers from Delhi
Malatesh Karabisti wrote:From K & B Book
"Hey compiler, please accept any List with a generic type that is of type Dog, or a super type of Dog.
Nothing lower in the inheritance tree can come in, but anything higher than Dog is OK."
SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Malatesh Karabisti wrote:From K & B Book
public void addAnimal(List<? super Dog> animals)
is essentially, "Hey compiler, please accept any List with a generic type that is of type Dog, or a supertype of Dog.
Nothing lower in the inheritance tree can come in, but anything higher than Dog is OK."
I think my source of confusion is these words still these words are not very clear to me ?
Venu Chakravorty wrote:
Of course the method can accept any supertype of Dog or Dog itself. We get the error when we are adding elements to the list
SCJP6.0,My blog Ranchers from Delhi
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Consider Paul's rocket mass heater. |