File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Error K&B book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic

Error K&B book

victor kamat
Ranch Hand

Joined: Jan 10, 2007
Posts: 247
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.

import java.util.*;

public class Test
public static void main(String... args)
List<String> Sla = new ArrayList<String>();
List<? extends String> Dog = new ArrayList<String>();

Dog = Sla;

for (String d: Dog)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You may remember that you posted this before

Adding null is allowed but is rather pointless.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
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
It's not a secret anymore!