Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

refrences

 
Arnb Sen
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Output is cat. Initially I thought the output was dog.

My reason :

"b = a" means b points to wherever a points. So after statement a = new String("dog");, a points to "dog" and hence, b should also point to "dog". Thus, after "c = b", c should point to "dog".

After the output I think :

"b = a" means b points to where a currently points. If later a points somewhere else, it does not change where b points.

Is this correct ?
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got it!
 
Arnb Sen
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

Thanks for the confirmation
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic