day09-继承中构造方法的访问特点

This commit is contained in:
2026-05-23 10:23:12 +08:00
parent 9c41ddb63e
commit b5a8af3ffb
3 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package com.inmind.extends_constructor04;
/*
继承中构造方法的访问特点
1.创建子类对象时,一定会调用父类的构造方法
2.super调用父类的构造方法时必须在子类的构造方法的第一行
3.super可以调用父类的有参构造方法。
*/
public class Demo05 {
public static void main(String[] args) {
//创建子类对象
Zi zi = new Zi();
//创建父类对象
Fu fu = new Fu(10);
System.out.println("程序结束");
}
}