Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
reference
communitycreator
pointer

What is a reference in Java?

abhilash

A reference is like a pointer to memory. When an object is created from a class, Java allocates enough memory required to store the object.

When the newly created object is assigned to a variable, the variable gets the value of the reference to the object, but not to the object itself.

Here, the reference assigned to the variable is the memory address where the object is stored.


Student studentVariable = new Student();

In the example above, the address of the Student object gets assigned to the studentVariable.

RELATED TAGS

java
reference
communitycreator
pointer
RELATED COURSES

View all Courses

Keep Exploring