Note:
variables : In essence, a variable is actually a small area of memory (stack) that uses variable names to access the area. Therefore, each variable must be applied (declared) before it is used, and then it must be assigned before it can be used.
Divided by the declared location:
- Local variable: A variable defined inside a method or statement block.
- Member variable: A variable that is defined internally by a method outside of a class.
- Note: Outside the class (outside the curly braces that correspond to the class), you cannot have a declaration of a variable.
By the data type that belongs to:
- Basic data type variable (inside stack)
- Boolean type only with Ture and false
- The char type represents a single character, enclosed in single quotation marks.
Example: Char a= ' a ', b= ';(characters can be letters, Chinese, symbols, etc.)
char c = ' \u0061 ';(can be represented by Unicode encoding, two bytes per character)
char d = ' \ n '; ' \ n ' represents a newline (you can also use the escape character ' \ ' to convert the character following it to another meaning)
- Reference data type variables (within the heap)
Constants : Constants are represented by a string, and the values of the character and string constants are two and cannot be changed. (Use the final keyword)
Java Memory analysis