package java面向对象;
/**
* 测试super关键字
*/
public class TestSuper {
public static void main(String[] args) {
new childcla();
}
}
class fathercla{
public fathercla(){
System.out.println("输出fatherclass");
}
public void say(){
System.out.println("i love singing");
}
}
class childcla extends fathercla{
public childcla(){
super();//继承父类时,构造方法首先调用super(),不管你写还是不写
System.out.println("输出childclass");
super.say();//super可以直接调用父类的方法和属性
}
}
转载于:https://www.cnblogs.com/zzzao/p/10890170.html