Results 1 to 3 of 3

Thread: Objects

  1. #1
    Join Date
    Apr 2010
    Location
    CHITTOR
    Posts
    2
    Rep Power
    0

    Default Objects

    Hi,
    i am very confusing about class objects and references.what is the difference between object and reference?

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by sudhakar reddy View Post
    Hi,
    i am very confusing about class objects and references.what is the difference between object and reference?

    in memory references are stored on the stack and objects are stored on the heap. as the name suggest the reference holds the reference (an adress) that points where the object is stored on the heap. the object on the heap contains all memebers, that is member-variables and the member-methods. in java when you declare "MyObject o" only the reference o is created and if you want to have an object on the heap you have to use the reserved word new, example "MyObject o = new MyObject();" now, if you have two object o1 and o2 when you say o1==o2 that you are looking if their references are the same. logically, when o1==o2 is true, then also the objects must be equal. in general for comparing the content of two objects the method isEquals is used.

    there are books dedicated to answer your question. so it's not possible to have all details in a short post.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Bannow: welcome the forum. Your question is quite important and as such should be in its own thread, not in a hijacked one. Please feel free to create a new thread and re-ask your question. Thank you for your cooperation.

Similar Threads

  1. Objects
    By Silverlining in forum New To Java
    Replies: 3
    Last Post: 11-11-2009, 03:36 PM
  2. Replies: 1
    Last Post: 01-22-2009, 05:25 PM
  3. Two Objects
    By losintikfos in forum New To Java
    Replies: 3
    Last Post: 11-14-2008, 08:04 PM
  4. 1 to 1 Objects
    By this.that in forum New To Java
    Replies: 4
    Last Post: 08-07-2008, 11:09 PM
  5. how many objects ?
    By kevinsong in forum Advanced Java
    Replies: 16
    Last Post: 07-16-2008, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •