File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes sample code in Chapter 7 of K&B SCJP 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "sample code in Chapter 7 of K&B SCJP 6.0" Watch "sample code in Chapter 7 of K&B SCJP 6.0" New topic
Author

sample code in Chapter 7 of K&B SCJP 6.0

zheng li
Ranch Hand

Joined: Jun 16, 2009
Posts: 56


it's written in the book that
We get one error
kathy% javac1.5 RentalGeneric.java
RentalGeneric.java:38: cannot find symbol
symbol : method add(Cat)
location: interface java.util.List<Car>
carList.add(new Cat("Fluffy"));
1 error


But on my computer, everything is just fine. no compiler error and no runtime exception.
java6(java5), eclipse, windowxp

Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
You can't have that error in your code, because you have forgotten to add this line:

This list works for cars, but not for cats called Fluffy.
cheers
Bob


SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
zheng li
Ranch Hand

Joined: Jun 16, 2009
Posts: 56
oh, yes, you are right.
it's Cat not Car.
Thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sample code in Chapter 7 of K&B SCJP 6.0
 
Similar Threads
ArrayList.get incompatible type
Overload or Override..How??
Doubt on generics once again
generics... page 598
Customize Sortling