class Outer { class Inner { private int i; public Inner (int i) { this.i = i; } public int value () { return i; } } public Inner getInnerInstance () { Inner in = new Inner (11); return in; } } public class Test { public static void main(String[] args) { Outer out = new Outer (); Outer.Inner in1 = out.getInnerInstance(); Outer.Inner in2 = out.new Inner(10); System.out.println(in1.value()); System.out.println(in2.value()); } }