Java- Java
javap MyOuter$MyInner
, :
public class MyOuter$MyInner extends java.lang.Object{
final MyOuter this$0;
public MyOuter$MyInner(MyOuter);
void dostuff();
}
, , , -. , Inner.
MyOuter.MyInner mi = mo.new MyInner(), , .
This is done automatically by the compiler, and therefore you cannot link the creation of your inner class with the creation of the outer class simply because the outer instance must already exist by the time the inner is created.
You can, however, create a chain of constructors between other declared constructors of your inner class.
For example, if such a code looks like this:
public class MyOuter
{
private int x= 10;
public class MyInner
{
private int y = 0;
public MyInner(){
this(10);
}
public MyInner(int value){
this.y = value;
}
void doStuff(){
System.out.println("The value of x is "+x);
}
}
}
Here I am linking constructors to an inner class.
Again, the decompiler provides an interpretation of all this to make sure that the external instance is passed as a parameter to the internal:
public class MyOuter$MyInner extends java.lang.Object{
final MyOuter this$0;
public MyOuter$MyInner(MyOuter);
public MyOuter$MyInner(MyOuter, int);
void doStuff();
}
source
share