• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 82
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Tomendra Singh
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Larry, but please can you or anyone tell me it with some java example. please put very simple examples.
 
Tomendra Singh
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot fred,thank you very very much. now i have understood.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic