測試1測試
public class C { public C(){ System.out.println("C"); } }
public class Cat extends C { private String name; public Cat(){ System.out.println("cat null"); } public Cat(String name){ System.out.println("cat"); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
public class ChildCat extends Cat { public ChildCat(){ System.out.println("ChildCat"); } public ChildCat(String name) { super(name); System.out.println(name); } }
public class TestExtendCat { public static void main(String[] args) { ChildCat c = new ChildCat(); } }
測試2this
測試3code
public class ChildCat extends Cat { public ChildCat(){ System.out.println("ChildCat"); } public ChildCat(String name) { //super(name); System.out.println(name); } }