1:static keywords
1) provides a separate space store for the shared data of the object.
2) The modified method can be called directly by the class name
Cons: 1) long life cycle.
2) Access restrictions (only static access)
It can have static methods, static classes, static variables
2:super keywords
1) Use the Super keyword to call the parent class's member variables and member methods.
Format 1:super. member variables
Format 2:super. member method ([Parameter 1, Parameter 2 ...])
2) Calling the constructor of the parent class using the Super keyword
Format 1:super ([parameter 1, Parameter 2 ...])
Summary: This represents the current object (can be output or address). Super represents parent class (cannot output address)
* It is generally compared with this keyword: 1. Can represent a constructor pass. This (a, b) means that another constructor is called. This is a special syntax, not a variable, not a type. 2. Can be used inside a non-static member of a class to represent the current object. At this point, this is a final normal variable, which has a static type, which is the class C itself; it has a dynamic type, which is the type of the current object. You can call member functions on it, pass it to other functions, and so on. As long as a final variable of type C can appear, it can appear.
3:final keywords
Here are some features:
1) The final modified class cannot be inherited
2) Final retouching method cannot be overridden by a quilt class
3) Final-Modified variables (member variables and local variables) are constants and can only be assigned once.
*FINAL,STATIC,PRIAVTE cannot be shared with abstract
-----------------------This paragraph from the Internet-------------------------------------
The final class cannot be inherited, there are no subclasses, and the methods in the final class are final by default.
The final method cannot be overridden by a method of a class, but can be inherited.
The final member variable represents a constant, which can only be assigned once, and the value will no longer change after the value is assigned.
Final cannot be used to modify a construction method.
Note: The private member method of the parent class is not overridden by the class method, so the private type method defaults to the final type.
1,final class
The final class cannot be inherited, so the member methods of the final class have no chance of being overwritten, and the default is final. In the design class, if the class does not need to have subclasses, the implementation details of the class are not allowed to change, and it is certain that the class will not be extended, then it is designed as the final class.
2. Final Method
If a class does not allow its subclasses to overwrite a method, you can declare this method as the final method.
There are two reasons for using the final method:
First, lock the method to prevent any inherited classes from modifying its meaning and implementation.
Second, efficient. The compiler goes into an inline mechanism when it encounters a call to the final method, greatly improving execution efficiency.
Public classTest1 { Public Static voidMain (string[] args) {//TODO automatically generate method stubs} Public voidF1 () {System.out.println ("F1"); } //methods that cannot be overridden by a quilt class Public Final voidF2 () {System.out.println ("F2"); } Public voidF3 () {System.out.println ("F3"); } Private voidf4 () {System.out.println ("F4"); } } Public classTest2extendsTest1 { Public voidF1 () {System.out.println ("Test1 Parent class method F1 is overwritten!"); } Public Static voidMain (string[] args) {Test2 T=NewTest2 (); T.F1 (); T.f2 (); //call the final method inherited from the parent class .T.F3 ();//call a method that inherits from the parent class .//t.f4 ();//call failed, cannot inherit from parent class} }
3. Final variable (constant)
A constant is represented by a final modified member variable, which cannot be changed once the value is given!
There are three final modified variables: Static variables, instance variables, and local variables, representing three types of constants, respectively.
As you can see from the example below, once the initial value is given to the final variable, it cannot be changed.
In addition, when the final variable is defined, it can be declared without giving the initial value, which is also called the final blank, and in any case the compiler ensures that the blank final must be initialized before it is used. However, final whitespace provides greater flexibility in the use of the final keyword final, so that the final data members in a class can be implemented differently depending on the object, but with the same characteristics that remain constant.
----------------- This paragraph from the Internet -------------------------------------
4. What does static and final piece mean?
Static final is used to modify member variables and member methods, which can be simply understood as "global constants"
the To the variable, which means that once the value is given it cannot be modified and is accessible through the class name .
For methods, the representation is not overwritten and can be accessed directly through the class name.
static method
Static methods can be called directly from the class name, and any instance can also be called, so a static method cannot use the This and Super keywords, and cannot directly access the instance variables and instance methods of the owning class (that is, member variables and member methods without static). Only static member variables and member methods of the owning class can be accessed. Because instance members are associated with specific objects!
Because the static method is independent of any instance, the static method must be implemented, not abstract.
Analysis of static,super,final keywords in Java