This is the foundation. The following program analyzes the result first. If the result is correct (the result is output in a white font), you are familiar with java class initialization. If not, review it.
Package nie. test. extend;
/** Sub-constructor initialization process:
* @ Author dotjar
* 1. Parent static domain
* 2. Parent static Block
* 3. substatic domain
* 4. Sub-static Block
* 5. Parent common domain
* 6. Parent common block {}
* 7. Parent Constructor
* 8. subnormal domain
* 9. Sub-common block {}
* 10. Sub-Constructor
*/
Public class Test {
Public static void main (String [] args ){
New Son ("s ");
}
}
Class Father {
Static protected String s = "father_static_property_string"; // 1
Protected String B = "father_normal_property_string"; // 5
Static {
S = "o"; // 2
System. out. print ("d ");
System. out. print (s );
}
{
B = "r"; // 6
System. out. print ("");
System. out. print (B );
}
Father (){
This ("@");
System. out. print ("1"); // 8
}
Father (String s ){
System. out. print (s); // 7
}
}
Class Son extends Father {
Public static String s = "son_static_property_string"; // 3
Public String B = "son_normal_property_string"; // 9
Static {
S = "j"; // 4
System. out. print ("t ");
System. out. print (s );
}
{
B = "3"; // 10
System. out. print ("6 ");
System. out. print (B );
}
Son (){
System. out. print ("."); // 11
}
Son (String s ){
This ();
System. out. print ("com"); // 12
}
}
After testing your output, you can select the next line and check it.