class A { int x=10; void f1() { System.out.println("this if f1 method"); } void f2() { B ob=new B(); ob.f4(); } class B { int y=30; void f3() { System.out.println("x="+x); f1(); } void f4() { System.out.println("this is f4 method"); } }; static class C { void f5() { System.out.println("this is f5 method"); } } }; public class Main { public static void main(String[] args) { A oa=new A(); oa.f2(); A.B ob=new A().new B();// non static inner class object ob.f3(); A.C oc=new A.C(); // static inner class object oc.f5(); } }
this is f4 method
x=10
this if f1 method
this is f5 method
Note:
Outer class or external class cont be declare either static or final class.