fork download
  1. /* Name of the class has to be "Main" only if the class is public. */
  2. class Ideone
  3. {
  4. public enum HeaderType {
  5. MARKER("MA"),
  6. WIDTH("WI");
  7. // FOO(), BAR; Won't compile
  8.  
  9. private final String name;
  10.  
  11. private HeaderType(String name) {
  12. this.name = name;
  13. }
  14.  
  15. public String getName() {
  16. return this.name;
  17. }
  18. }
  19.  
  20. public static void main(String[] args) {
  21. for (HeaderType headerType : HeaderType.values()) {
  22. System.out.println(headerType.getName());
  23. }
  24. System.out.println(getHeaderName(HeaderType.MARKER));
  25. }
  26.  
  27. // Replacement for old method, although actually not necessary
  28. private static String getHeaderName(HeaderType headerType) {
  29. return headerType.getName();
  30. }
  31. }
Success #stdin #stdout 0.11s 320576KB
stdin
Standard input is empty
stdout
MA
WI
MA