在下面的代碼中,輸出是:S1S2。爲什麼我們得到那個結果?爲什麼我們有這種情況下的輸出:S1S2?
public class S1 {
public static void main(String[] args) {
new S2();
}
S1(){
System.out.print("S1");
}
}
class S2 extends S1{
S2(){
System.out.print("S2");
}
}
查找[構造函數鏈接](http://www.leepoint.net/notes-java/oop/constructors/constructor.html)。 – 2012-03-20 00:32:32
對於[SSCCE](http://sscce.org/)的好問題+1。 – 2012-03-20 00:34:38