Home > Java > JavaBase > body text

what is java reference

angryTom
Release: 2019-11-13 10:12:56
Original
3532 people have browsed it

what is java reference

What is java reference

1. First, you have to understand what a variable is. The essence of a variable is a small memory unit. This small piece of memory stores the value of the variable

For example, int a = 1;

a is the name of the variable, and 1 is the value of the variable.

When a variable points to an object, the variable is called a reference variable (recommended tutorial: java tutorial )

For example A a =new A();

a is a reference variable. It points to an A object. It can also be said that it refers to an A object. We operate the A object by manipulating this a. At this time, the value of variable a is the address of the object it refers to

The reference data type is one of the two major data types of Java

The reference data type is created when , first allocate a piece of memory to its reference (handle) on the stack, and the specific information of the object is stored in the heap memory, and then the reference on the stack points to the address of the object in the heap.

Reference data types include: classes, interface types, array types, enumeration types, annotation types, string types;

java another big data Types are basic data types, including numeric, character and Boolean.

When a basic data type is created, a memory is allocated to it on the stack, and the value is stored directly on the stack;

is the alias of this data, just like a person's nickname Similarly, when you deal with this nickname, you are dealing with the individual itself equivalent to the reference in C, that is, &, which stores the instance address of a certain class

The above is the detailed content of what is java reference. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!