2017-09-05 70 views
-2

我encoutered一個錯誤,當我這樣的程序:構造RdsHttpErrorResponse(xxxErrorCode.Common)是未定義

new RdsHttpErrorResponse(xxxErrorCode.Common.REQ_NULL) 

首先,我哈瓦一個構造函數,像這樣:

public RdsHttpErrorResponse(ErrorCode code) 
{ 
    this.setErrorCodeAndMgs(code, null); 
} 

而且,我的枚舉常見的,像這樣:

public class xxxErrorCode{ 
    public interface ErrorCode 
    { 
     public int toInt(); 

     public String toStr(); 
    } 

    /** 
    * xxxErrorCode Common 
    */ 
    public enum Common implements ErrorCode 
    { 
     REQ_NULL(6, "CloudFS.0006"), // req_body is null 
     ... 
     private int code; 

     private String strCode; 

     private Common(int code, String strCode) 
     { 
      this.code = code; 
      this.strCode = strCode; 
     } 

     public int toInt() 
     { 
      return code; 
     } 

     public String toStr() 
     { 
      return strCode; 
     } 
    } 
} 

我的枚舉常見的實現了ErrorCode接口。 爲什麼會出現這個錯誤?

+0

尋求調試幫助的問題(「爲什麼這個代碼不工作?」)必須包含所需的行爲,特定的問題或錯誤以及在問題本身中重現問題所需的最短代碼。沒有明確問題陳述的問題對其他讀者無益。請參閱:如何創建[mcve]。使用「編輯」鏈接來改善你的*問題* - 不要通過評論添加更多信息。謝謝! – GhostCat

回答

0

我已經知道這個問題的答案。 原因是,我複製一個名爲xxxErrorCode定義一個新的xxxErrorCode類,但「進口」仍是舊xxxErrorCode。

因此,內部接口錯誤代碼是差異完全!(即使它們是相同的)

+0

「導入」仍然是舊的xxxErrorCode,而舊的xxxErrorCode.ErrorCode.Yes,它需要兩個「導入」。 – cleverlzc