Static:
1. In a variable, the method is pre-decorated to represent static methods, static variables.
2.
Static {}
This form is a static block of code used to initialize a variable that is also modified by the final static. (Of course, the more common way is to assign values directly at the variable)
The contents of the static code block are run directly at the time the class is loaded
Package Com.main; /** */Publicclass hellojava {static{ System.out.println ("This line would be default initialized"); } Public Static void Main (string[] args) { System.out.println ("Hello World");} }
The results of the operation are as follows:
This line would be default initialized
Hello World
Others such as static variables that are called directly with the class name are no longer detailed.
Final:
1. The uninitialized final member variable can be initialized only once in the constructor.
2. The uninitialized final local variable can be initialized only once in the owning code block.
Otherwise you will get an error.
Static keyword and final keyword in Java