I have compiled the following code (Methods and variables are elided for brevity):
// Outer.java
public class Outer
{
private class Inner
{
}
void someMethod()
{
Inner inObj = this.new Inner();
}
public static void main(String s[])
{
Outer outerObj = new Outer();
}
}
When I listed the classes created, it displayed the following:
Outer$1.class
Outer$Inner.class
Outer.class
Outer and Outer$Inner appear logical. What is the purpose of Outer$1 class? What is the order of creation of these in time scale?
Curious. I'm not sure what this is for. But if you decompile the classes, you can see how it is used:
So,
Outer$1seems to contain nothing - not even a default constructor. But a reference to aOuter$1has to be passed toOuter$Innerto construct it. Mysteriously, the value passed insomeMethodisnull(line 5 insomeMethod).