File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assigning references Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assigning references" Watch "Assigning references" New topic
Author

Assigning references

mrudul joshi
Ranch Hand

Joined: Nov 12, 2003
Posts: 54
What does the following statement mean?

Assigning references does not copy the state of the source object on the right hand side, only the reference value.

What is exactly, the state of the source object?
Thanks
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
Originally posted by mrudul joshi:
What does the following statement mean?

What is exactly, the state of the source object?
Thanks

In this context, the state of the object can be thought of as the actual object binary pattern. When you assign one reference to another, the original object remains intact, while the contents of the assigned reference (its binary pattern) gets copied into the reference variable to the left, so both references refer to the same object on the heap. Remember, when you use == operator, you compare the bit patterns?
This has to do with the Java pass-by-value notation - everything is passed by value, even references.
mrudul joshi
Ranch Hand

Joined: Nov 12, 2003
Posts: 54
That was really good!
Thanks for clearing my concept.
bye
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning references