aspose file tools*
The moose likes Beginning Java and the fly likes what is Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is "reference of any object" and "object"" Watch "what is "reference of any object" and "object"" New topic
Author

what is "reference of any object" and "object"

Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
hi people,
i am confuse in that what is "reference of any object" and "object".
actually i know what is object but i am confuse in that what is "reference of an object."
please provide any simplest example with some code so that i can understand better.

thank you.


Strength Is Life,Weakness Is Death- Swamy Vivekanand.
SCJP 5.0(87%)
Larry Frissell
Ranch Hand

Joined: May 16, 2008
Posts: 82
    
    2
In another thread Fred Rosenberger stated it best
personally, i think of references as notecards with address on them, and they refer to a house.

when you 'pass an object' into a method, you are really passing a copy of the reference. So, you are effectively passing a copy of the address.


So an object is a house, the reference is the address of where the house is located.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11497
    
  16

when you say

MyObject foo = new MyObject();

two things are created. an object is made on the heap somewhere. you don't have direct access to this. this is the house.

a reference called "foo" is made. this is the notecard, which you DO have. the '=' then writes the address on the card.

so in this case, there is an object somewhere. 'foo' is the reference to the object - it's how you get to the object.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
thanks Larry, but please can you or anyone tell me it with some java example. please put very simple examples.
Tomendra Singh
Ranch Hand

Joined: Jun 28, 2008
Posts: 47
thanks a lot fred,thank you very very much. now i have understood.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is "reference of any object" and "object"