标签:
如果希望在子类中,去调用父类的构造方法,要求在子类的构造函数调用
example如下:
package test; /* * 如果希望在子类中,去调用父类的构造方法,要求在子类的构造函数调用 * */ public class test4 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Kkk kk = new Kkk(12,"dd"); } } class Base { int age; String name; public Base(int age,String name) { System.out.println("base"); this.age=age; this.name=name; } } class Kkk extends Base { public Kkk(int age,String name) { super(age, name); System.out.println("Kkk"); } }
标签:
原文地址:http://www.cnblogs.com/lt132024/p/5951703.html