Skip to content

Instantly share code, notes, and snippets.

@pozdneev
Created January 12, 2018 11:33
Show Gist options
  • Save pozdneev/31be2844051cb2dd446bba458daa43eb to your computer and use it in GitHub Desktop.
Save pozdneev/31be2844051cb2dd446bba458daa43eb to your computer and use it in GitHub Desktop.
Demonstrates the String representation of a Java enum
public class SpeakingEnum {
public static enum SPEAKING_ENUM {
SOME_VALUE,
SOME_OTHER_VALUE;
public void speak() {
System.out.println("this=" + this);
}
}
public static void main(String [] args) {
SPEAKING_ENUM se1 = SPEAKING_ENUM.SOME_VALUE;
SPEAKING_ENUM se2 = SPEAKING_ENUM.SOME_OTHER_VALUE;
se1.speak();
se2.speak();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment