Second, the basic data types

1, the basic data types

  1. Numeric
    1. Integer types: byte, short, int, long
    2. Floating-point types: float, double
  2. Character: char
  3. Boolean: boolean

2, variables and constants

  1. Variable: When we define variables, is to tell the compiler that we need much space to store this value, and this value will become, so called variable.

Data area (DATA) ----> program area (Program) ----> System area (OS)

  • During program execution, values ​​are placed in the data area, the program is read into memory in the program area.
  1. Member variables: variables defined in the body called a class member variables.
    1. Examples of variables: x as an example
    2. Static variables: y is a static variable, can be preceded by static,
      the difference is that static variables can be accessed in the whole application - name of the class variable name. .
public class First{
    int x = 45;
    static char y = "a";
    public static void main(String[] args){

    }
}

3, local variables

  1. Class variables defined in the body of the method is called local variables.
    [Comment]: when calling the method, create memory memory space for local variables, after completion of the method of execution, release the corresponding memory space to achieve garbage collection.

Guess you like

Origin www.cnblogs.com/hasz/p/12194608.html