1. in inheritance, for example
Class
{
Void show (){}
}
Class B extends
{
Static void show () {}// this is incorrect because the non-static method of the parent class cannot be overwritten as a static method in the subclass during inheritance.
}
2 Class
{
Int I;
A (int I)
{
This. I = I * 2;
}
}
Class B extends
{
Public static void main (string [] ARGs)
{
B = new B (2 );
}
B (int I)
{
System. Out. println (I );
}
}
In this example, because subclass B inherits a, when executing the constructor of the subclass, if a constructor of the parent class is not explicitly specified in the subclass, will first execute the non-parameter constructor of the parent class, but class A does not have such a function, so a compilation error occurs. therefore, you can add super (2 );
3
A static method cannot access instance (non-static) variables
Int x = 12;
Static void ()
{
Output X; // Error
}
Static Method B cannot access non-static method
Void go ()
Static void domore ()
{
Go ();
}
C static method can access the Jingtai method or variable
Static int X;
Static void ()
Static void B ()
{
Access X;
A ();
}
4. Static methods must be implemented, and abstract is an enemy, such
Static abstract void () {...} is incorrect
5. The super keyword cannot be found in static methods, because Super is related to the instance of a specific class and is in conflict with static.