I'm learning Enum and got confused about 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 the javac Check.java
I'm getting the following .class
files.
Check.class
Currency$1.class
Currency.class
Why Currency$1.class
is created? and how? what is the reason behind?
I know $ sign for inner classes and 1 mean anonymous class 1. But why in this code it created as there is no inner class.