I. Heap and stack (brief introduction) 1. Stack
Stack space relative to the heap is small, there is a system of space allocation and recycling work. The read efficiency of the stack is very high.
2. Heap
The heap space is relatively large, like a large warehouse. The garbage collector (GC) is working on space reclamation. The heap is less efficient to access
Two. Data type (emphasis)
In order to make better use of the memory space, the data types are divided in the programming language. The total can be divided into two main categories: basic type, reference type
- Basic type
- Numeric type
- long:64 bits of Integer data
- int:32 bits of Integer data
- Short:16 bit integer data
- Byte:8 bit integer data
- double:64 bit floating point number (double-precision floating-point number)
- float:32 bit floating point number (single-precision floating-point number, the data is usually followed by F, otherwise the default is DOUBL
- Character type
- Char: Character type, 16-bit Unicode character (minimum \u0000). The contents of a character type are usually enclosed in single quotation marks. Character content has a length (there can be at most one content in the content).
- Boolean type
- Called a Boolean type, which contains true and false, used for "true" and "false" in Pepsi Life
- Reference type
- class, Interface (interface), string (string), array
- The string type is called a string type, which is made up of a series of characters (char), and the value of string needs to be caused by "".
- Object
- object is the parent class of all types
- For conversions between basic data types such as (real arrows represent no data loss conversions, virtual arrows represent conversions that may have loss of precision):
Iv. variables and identifiers (emphasis)
A variable is actually a piece of memory that stores data.
- The process of declaring a variable is actually applying a piece of memory space and making a name for the space.
- Assigning a variable is actually storing a data in the memory space. The variable name represents the space's alias, and the type represents the size of the space
- Variable
- Variables: In Java, each variable belongs to a variety of types (type). When declaring a variable, the type to which the variable belongs is preceded, followed by the variable name.
- Initialize variable: After declaring a variable, the variable must be explicitly initialized with an assignment statement.
4. Constants
In Java, using the keyword final to declare a constant (the final keyword means that the variable can only be assigned once, and once assigned, it cannot be changed again.) In practice, the constant name uses uppercase. )
java--variables and data types