Created
August 17, 2016 16:29
-
-
Save anchoo2kewl/3aa11646ff278dac084ce0162d4d1b0d to your computer and use it in GitHub Desktop.
Enum in Java for Error codes with descriptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum test { | |
A(-1, "Text 1"), | |
B(-2, "Text 2"); | |
private final int code; | |
private final String description; | |
private test(int code, String description) { | |
this.code = code; | |
this.description = description; | |
} | |
public String getDescription() { | |
return description; | |
} | |
public int getCode() { | |
return code; | |
} | |
@Override | |
public String toString() { | |
return code + ": " + description; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment