You can simply write your code inside the listing itself.
public enum MyEnum { DOG, CAT; public static void main(String[] args) { MyEnum dog = MyEnum.DOG;
Another place where private enumerations can be links without their class is in the switch statement:
private static enum MyEnum { DOG, CAT } public static void main(String[] args) { MyEnum e = null; switch (e) { case DOG: case CAT: } }
brianegge
source share