File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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


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

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
I agree. Here's the link:
subject: refrences
It's not a secret anymore!