Variables and constants
1. Variable: a sequence of letters and numbers starting with a letter.
1.1 letters and numbers here are wider than most other programming languages.
1.2 is case sensitive and the length is unlimited.
1.3 if you want to know which unicode characters belong to java letters, you can use isJavaIdentifierStart and isJavaIdentifierPart in the Character class to check.
1.4 variables must be used only after initialization; otherwise, java considers them wrong.
For example, int x;
System. out. println (x); // Error -- variable is not initialized
1.5 java does not differentiate the Declaration and definition of variables.
2. constants: Use final life constants in java.
The 2.1 keyword final indicates that the variable can be assigned only once. Once assigned, the variable name cannot be modified.
2.2 In java, a constant is often used in multiple methods in the class and usually becomes a class constant. You can use the static final keyword to set class constants.
2.3 const is a reserved keyword in java and is not used. final must be used in java to define constants.
This article is from the "Myworld" blog