What is the result of the following code?
I encountered twice the construction of a inner class
Outter.Inner in = out.new Inner();
but only in books. I never had any use of such a construct.
If you don't find out just try it :)
class Outter {
private int value;
private Inner in = new Inner();
Outter() {
value = 41;
}
void print() {
in.print();
}
class Inner {
Inner() {
print();
}
void print() {
System.out.println(value++);
}
}
}
public class Main {
public static void main(String[] args) {
Outter out = new Outter();
out.print();
Outter.Inner in = out.new Inner();
in.print();
}
}