Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The difference between JAVA's basic data types and reference data types
The difference between JAVA's basic data types and reference data types
The difference between basic data types and reference data types of JAVA;

1, and the basic data types are: byte: the smallest data type in Java; Short: short integer; Int: integer; Long: long integer; Float: floating point type; Double: double-precision floating-point type; Char: character type; Boolean: Boolean type.

Reference data types are: class, interface type, array type, enumeration type and comment type.

2. When the basic data type is created, a piece of memory is divided on the stack, and the value is directly stored on the stack.

When creating a reference data type, you must 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.

3. When data is passed as parameters, the basic data type is value passing, and the reference data type is reference passing (address passing).