I am learning Enum and am confused in this code.
enum Currency{ PENNY, NICKLE, DIME, QUARTER; @Override public String toString() { switch (this) { case PENNY: System.out.println("Penny: "); break; case NICKLE: System.out.println("Nickle: "); break; case DIME: System.out.println("Dime: "); break; case QUARTER: System.out.println("Quarter: "); } return super.toString(); } }; public class Check{ public static void main(String[] args){ } }
When I compiled javac Check.java , I get the following .class files.
Check.class Currency$1.class Currency.class
Why is Currency$1.class created? And How? what is the reason? I know the $ sign for inner classes and 1 anonymous class 1. But why is it created in this code because there is no inner class.
user6117584
source share