I want to override toString()
for my enum, Color
. However, I can't figure out how to get the value of an instance of Color
inside the Color
enum. Is there a way to do this in Java?
Example:
public enum Color {
RED,
GREEN,
BLUE,
...
public String toString() {
// return "R" for RED, "G", for GREEN, etc.
}
}