A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
Error K&B book
Joined: Jan 10, 2007
Feb 20, 2007 13:55:00
K&B pg 610, fourth bullet states that the generic class List<? extends Dog> can be accessed but not modified.
The code shows that this incorrect.
public static void main(
List<String> Sla = new
List<? extends String> Dog = new
Dog = Sla;
for (String d: Dog)
Joined: Aug 03, 2002
Feb 20, 2007 14:03:00
You may remember that you posted this
Adding null is allowed but is rather pointless.
Ask a Meaningful Question
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Error K&B book
Type of the Generic List
How Does the Compiler Know Not To Allow Adding to a Generic List With a Wildcard?
Generics doubt in K&B p.574
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015