A reference can be thought of as creating a shortcut to a window. A variable that contains the address of a class or other object is called a reference variable, which allows you to access the class or other object that the address points to. Instance refers to a class created on memory. It's a term that comes naturally when you study about classes.
Stirng[] strArr = new String[]{"a", "b"};
When you create a string array object, it is created somewhere in memory. The address of the memory would be 0x00123515. This is called a class object or instance.
You can access that instance from a variable called strArr. The variable that approaches the instance in this way is called a reference type variable.
int aNum = 5;
These variables are called primitive type variables.
Java has two types of variables: primitive type and reference type.
© 2024 OneMinuteCode. All rights reserved.