I am studying Java and wrote a very simple program. In it I can put enums in the top most level, but not inside a method. The way I see it, enums are almost like constants, so why not use them inside methods?
In my program, enum1 is allowed, but enum2 is not. Why?
enum enum1 {A, B, C};
public static void main(String[] args)
{
enum enum2 {A, B, C}; // only on a top level class or interface
}