Java中的Super()是super()用来调用父构造函数?请解释一下super().
3 回答
慕无忌1623718
TA贡献1744条经验 获得超4个赞
super(...)
class Animal { public Animal(String arg) { System.out.println("Constructing an animal: " + arg); }}class Dog extends Animal { public Dog() { super("From Dog constructor"); System.out.println("Constructing a dog."); }}public class Test { public static void main(String[] a) { new Dog(); }}
Constructing an animal: From Dog constructorConstructing a dog.
添加回答
举报
0/150
提交
取消