Java final data and javafinal data
Many programming languages have their own solutions to tell the compiler that a piece of data is a constant ". Constants are mainly used in the following two aspects:
1) The compile-time constant, which will never change;
2) A value initialized during running, we do not want it to change. Ss
For constants in the compilation period, the compiler (Program) can "encapsulate" the constant values into the required computing process. That is to say, the computation can be executed in advance during compilation, thus saving some runtime expenses. In Java, constants of these forms must belong to the basic data type (Primitives) and must be expressed using the final keyword.
Either the static or final fields can store only one data and cannot be changed.
If final is used along with the object handle, rather than the basic data type, its meaning is a bit confusing. For the basic data type, final converts the value to a constant, but for the object handle, final converts the handle to a constant. During the declaration, the handle must be initialized to a specific object. In addition, the handle cannot be changed to another object. However, the object itself can be modified. Java does not provide any means to convert an object directly into a constant.