What are references and instances?

Asked 2 years ago, Updated 2 years ago, 110 views

I'm studying Java and the address of the array is called a reference I have no idea about the reference, so I'm asking you a question. What are references and instances? I hope it's easy to understand because I'm a beginner.<<

<

java instance reference array

2022-09-22 18:05

2 Answers

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.


2022-09-22 18:05

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.


2022-09-22 18:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.