Issue
I have a Java project operated in Eclipse with the main executable file called GreatPlaces.java
. In my /bin
folder, I would assume to have just one CLASS file called GreatPlaces.class
. However, I have couple of them, except for GreatPlaces.class
I have also GreatPlaces$1.class
, GreatPlaces$2.class
... GreatPlaces$22.class
. Can anyone explain me this? Thanks.
Solution
Inner classes if any present in your class will be compiled and the class file will be ClassName$InnerClassName
. In the case of Anonymous inner classes, it will appear as numbers.
Example:
public class TestInnerOuterClass {
class TestInnerChild{
}
Serializable annoymousTest = new Serializable() {
};
}
For the above code, the classes that will be generated are:
TestInnerOuterClass.class
TestInnerOuterClass$TestInnerChild.class
TestInnerOuterCasss$1.class
Answered By - Jainendra
Answer Checked By - Marie Seifert (JavaFixing Admin)