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.
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
The dollar sign is used by the compiler for inner classes.
$
sign represents inner classes. If it has a number
after $
then it is an annonymous inner class. If it has a name
after $
then it is only an inner class.
So in your casese these are representing annonymouse inner classes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With