Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are the reference data types in java?
What are the reference data types in java?
There are two data types in Java, including eight basic data types and reference data types, all of which are reference data types except eight basic data types, and the eight basic data types are byte, short, int, long, char, Boolean, float and double respectively, as follows:

1, boolean: The data value is only true or false, which is suitable for logical calculation.

2. char: data of char type (character type) occupies 2 bytes in memory. Char data is used to represent characters in the usual sense, each character occupies 2 bytes, Java characters are encoded in Unicode, and the storage range of the first 128 bytes is between \ u0000 and \ ufff. Note that ""should be added when defining character data. For example, "1"is the character "1".

3.byte:byte-type data occupies 1 byte in memory, indicating the range of data storage:-128~ 127.

4.Short: Short (short integer) data takes up 2 bytes of memory.

5. int: data of int type (integer) occupies 4 bytes of memory.

6.long:long data takes up 8 bytes of memory.

7. float: data of float type (single precision floating-point type) occupies 4 bytes in memory. (Floating-point precision is 7-8 bits)

8.double:double type (double precision floating point type) data takes up 8 bytes of memory.

All the basic data types in Java have a fixed storage range and memory space, which is not affected by the specific operating system to ensure the portability of Java programs. Plastic data defaults to int data type and floating-point data defaults to double data type. If you want to represent long data or floating-point data, you should add L, L or F, F after the corresponding values, otherwise there will be compilation problems.

In other languages, such as C language, character data and integer data can be converted and stored in ASCII code, so character data can be treated as integer data.