我有類錯誤。 我有值errorCode。 我需要通過errorCode獲取字符串。如何創建分析功能
例如,int number = -2;
Errors.Parse(number).toString();
返回值#-2#The username is already in use.
public enum Errors {
UNKNOWN_ERROR(-1, "Unknown error"),
LOGIN_ALREADY_EXISTS(-2, "The username is already in use."),
LOGIN_OR_PASSWORD_NOT_CORRECT (-3, "LOGIN_OR_PASSWORD_NOT_CORRECT"),
NULL_POINTER (-4,"Null pointer exception"),
NOT_CORRECT_DATA (-5,"NOT_CORRECT_DATA");
private final int errorCode;
private final String message;
private Errors(int errorCode, String message) {
this.errorCode = errorCode;
this.message = message;
}
public int getErrorCode() {
return errorCode;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
return "#" + errorCode + "#" + message;
}
}
@simply丹尼斯,把這個方法裏面'錯誤'。 – mre
@simple denis,@mre是正確的。 – gouki