Till now I was having an understanding that when we define a class inside a class after compilation we get one outer.class and another outer$inner.class
I have got an example of enums with switch case
enum Apple{
Jonathan,GoldenDel,RedDel,Winesap,Cortland
}
class EnumDemo {
public static void main(
String[] args) {
Apple ap;
ap=Apple.RedDel;
System.out.println("Value of ap:"+ap);
//System.out.println(Apple.RedDel);
System.out.println();
//Compare two enum values
ap=Apple.GoldenDel;
if(ap==Apple.GoldenDel)
System.out.println("ap contains GoldenDel.\n");
//Use an enum to control a switch statement
switch(ap){
case Jonathan:
System.out.println("Jonathan is red.");
break;
case GoldenDel:
System.out.println("Golden Delicious is Yellow.");
break;
case RedDel:
System.out.println("Red Delicious is red");
break;
case Winesap:
System.out.println("Winesap is red.");
break;
case Cortland:
System.out.println("Cortland is red.");
break;
}
}
}
Here after compilation I am getting two files generated EnumDemo.class and EnumDemo$1.class why EnumDemo$1.class although I donot have any inner class.