Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sample code in Chapter 7 of K&B SCJP 6.0

 
zheng li
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
zheng li
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh, yes, you are right.
it's Cat not Car.
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic