<![endif]-->
class String ;
private age {
out "people static block" }
System. .println( );
People() {
System. .println( );
public ();
this name . = age;
out "people constructor arguments" }
String getName() {
return ;
public setName(String name) {
this name }
String getAge() {
return ;
public setAge(String age) {
this age }
class extends String ;
private grade {
out "student static block" }
System. .println( );
Student() {
super System. .println( );
Student(String schoolName, String grade) {
. = schoolName;
this grade System. .println( );
String getSchoolName() {
return ;
void . = schoolName;
String getGrade() {
return ;
void . = grade;
public Test2 {
public void Student s = Student();
new "aa" "bb" }
通过运行结果 , 那在加载类的时候 , 再加载子类 static 代码块 . 普通代码块 . 类的加载只执行一次 . 而调用子类的构造函数都是会先隐式的执行父类的无参构造函数 <FONT style="FONT-SIZE: 12pt" color="black" face=""">.