1. 程式人生 > >XXXXX() is undefined. Must explicitly invoke another constructor如何解決

XXXXX() is undefined. Must explicitly invoke another constructor如何解決

當父類已經有了一個或多個顯示的建構函式

public class Fu {
	Fu(String name){
	}
}


而你子類想寫個預設建構函式時:
<pre name="code" class="java">public class Zi extends Fu {
	Zi(){
	}
}


會報出錯誤,你僅需要在子類無參構造中:

	Zi(){
               super(null);
	}