What is difference between the following in java :
Object
Reference ID
Reference Variable
When I see sta
Emp e
This statement creates a reference variable 'e' in the stack.
new Emp()
This statement creates an object in the heap. An object is just a buffer or we can say "a chunk of memory". Hence , a buffer gets reserved in the heap. Thus the statement,
Emp e=new Emp()
passes the reference id of that object created in the heap to the reference variable 'e'.