Variables, objects and memory

First, what is a variable?

  • Look variable is stored data from the surface, but his essence is the storage location, there is a type of the variable to explain what type of value can be put to.
  • 7 types of variables: static variables, instance variables (this thing is dispensed on the Heap), array element (the value of the parameter, a reference parameter, an output parameter) in the three species with the methods, local variables (generally refers to said variable it appears in the method body, something that no longer Heap memory allocation on the stack).
  • Variable declaration: combination of modifiers (public static) This can not happen in the variable name + + + type initializer this can not happen 
  • Variable = variable name to the memory address corresponding to the starting point, the data type required for its storage for a memory area of ​​length
  1. Value type variable: no instance variables and instance together

                      

           2. The reference types of variables: the object instance data is stored in memory address

                     

 

3. The default values ​​of variables, instance variables default field is 0

 

Guess you like

Origin www.cnblogs.com/1521681359qqcom/p/11184387.html