aspose file tools*
The moose likes Beginning Java and the fly likes refrences Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "refrences" Watch "refrences" New topic
Author

refrences

Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145


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 ?


Regards,<br />Arnab
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

You got it!


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Arnb Sen
Ranch Hand

Joined: Feb 23, 2004
Posts: 145
Hi Michael,

Thanks for the confirmation
 
wood burning stoves
 
subject: refrences
 
Similar Threads
Collection - Chap 7 (Maps) (Problem in Understanding an example in K&B SCJP 1.6)
String object created twice with the same reference variable
Another passing by reference question
class question
Collection Example in K&B