Skip to content

Instantly share code, notes, and snippets.

@anchoo2kewl
Created August 17, 2016 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchoo2kewl/3aa11646ff278dac084ce0162d4d1b0d to your computer and use it in GitHub Desktop.
Save anchoo2kewl/3aa11646ff278dac084ce0162d4d1b0d to your computer and use it in GitHub Desktop.
Enum in Java for Error codes with descriptions
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