What is difference between the following in java :
Object
Reference ID
Reference Variable
When I see sta
Object is nothing it is just a memory area or buffer in a heap area where all the instance data members of a class are getting a memory.
Emp e = new Emp();
in the above statement e is a reference variable which hold the reference id of the object, however in for security purpose java is not allowing anyone to get the id of actual object it also can be self explanatory as we are using word reference id which redirects us that we are not getting the actual id of our object instead just a reference of it.
also reference id would be nomenclature as classname@hexadecimal representation of the # code of object.
I just made a program for displaying reference ID of an object.
class abc
{
int a=10;
int b;
}
class t extends abc
{
public static void main(String args[])
{
abc A=new abc();
System.out.println(""+A);
}
}
output : shockingly a hex string :
"abc@52e922"
Java maps the actual location of an object at a separate place in form of a hex string which is known as reference ID. It never displays actual location of it's object stored in the memory.