File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
EJB 3 in Action
this week in the
EJB and other Java EE Technologies
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
Generics adding to List (? extends Object)
How Does the Compiler Know Not To Allow Adding to a Generic List With a Wildcard?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014