top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

what is diff between object and reference in java

+3 votes
478 views
what is diff between object and reference in java
posted Nov 6, 2013 by Tulasi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
I think you are looking difference between an object variable and an object reference...

2 Answers

+1 vote

On the lower level of Java, a "reference" can be thought of like a pointer in C. It is essentially an integer which refers to (points to) a location in memory where the object data exists.

// "button" is a reference to a JButton with a "1" on it (the object).
JButton button = new JButton("1");

Source: http://wiki.answers.com/Q/Difference_between_reference_and_object_in_java

answer Nov 6, 2013 by Majula Joshi
+1 vote

Object occupies some memory to store all its members details . reference is like a variable having capability
to store the bits which gives us a way to access to stored object members.

answer Nov 8, 2013 by anonymous
...