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$1
seems to contain nothing - not even a default constructor. But a reference to aOuter$1
has to be passed toOuter$Inner
to construct it. Mysteriously, the value passed insomeMethod
isnull
(line 5 insomeMethod
).