+ 1

What is the difference between an object and an object reference in java?

8th Dec 2018, 12:25 PM
Mystery
Mystery - avatar
3 Respuestas
+ 17
 ● A reference variable points to an actual object , here is nice explantion on it : http://www.hacktrix.com/difference-between-object-and-reference-in-java
8th Dec 2018, 12:40 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 10
https://code.sololearn.com/cqa0MSc4pvDb/?ref=app
8th Dec 2018, 12:44 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 2
An object is an runtime instance of a class in memory(i.e. RAM) A reference is nothing but a variable that stores the memory address of the object Consider the following example: MyClass ref = new MyClass(); In the above statement, the RHS i.e. new MyClass() creates an object and return it's memory; and the reference variable ref stores that address. You can check what address the reference variable ref stores by the statement System.out.print(ref)
8th Dec 2018, 6:37 PM
Rishi Anand
Rishi Anand - avatar