Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chapter 3 - SELF TEST - Page 269

 
fadi aboona
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code:


the following output:


The answer in the book doesn't mention object c3, only c1 and the wrapper Short are eligible for collection.
 
Asad Zubair
Ranch Hand
Posts: 44
Eclipse IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fadi,
Please try and use the code tags to make it easier for your fellow ranchers to read your code and help you out. You can see below how nice it looks with the code tags
To answer your question, understand that c3 is not an object. It is a variable reference that could point to a CardBoard object. Here, c3 is pointing to the result of c1.go(c2) which turned out to be null. So c3 is not pointing at any object to begin with.



 
fadi aboona
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asad Zubair wrote:Hi Fadi,
Please try and use the code tags to make it easier for your fellow ranchers to read your code and help you out. You can see below how nice it looks with the code tags
To answer your question, understand that c3 is not an object. It is a variable reference that could point to a CardBoard object. Here, c3 is pointing to the result of c1.go(c2) which turned out to be null. So c3 is not pointing at any object to begin with.





Thanks Asad, you're truly Asad
i will envelope my code with the code tags going forward.
I missed that c3 is not an object yet, it's only a reference. There are so many details that i tend to forget!! you know i'm not young anymore and it's hard to remember :-(

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic