While extending the inner classes, we have to explicitly set some relation between the extending class and the outer class for this inner class. So, the issue is resolved when we go by the second approach. The other approach could be
public class Test{
class TestInner extends Outer.Inner{
TestInner(Outer o){
o.super();
}
public void show(){
System.out.println("in the test1 class!!");
}
}
public static void main(
String ar[]){
Test test=new Test();
Outer oo = new Outer();
Test.TestInner in=test.new TestInner(oo);
in.show();
}
}
Hope this solves the issue.