我正在做一個小型的Java遊戲,並在編譯時我得到了一個錯誤:java無效的方法聲明;返回初始化科目編號類型,運行
error:invalid method declaration;return type requied
public init() throws Exception {
^
第一個版本是公共無效的init,但我不能做這樣的,因爲我需要使用try {..} catch(Malformed ...)或編譯時我得到了另一個錯誤(需要抓住等等等等)。
這是代碼:
public void run() throws Exception{
try{
this.zz();
}catch(MalformedURLException me){
throw me;
}
this.zo();
}
公共無效的init()拋出異常 –
公衆詮釋init()拋出異常。添加返回類型。 – Veera