public class Outer1 { public static void main(String[] args) { Outer2 objOuter1 = new Outer2(); Outer2.Inner1 objInner1 = objOuter1.new Inner1(); objInner1.innerMethod1(); } } class Outer2 { public void makeInner() { Inner1 objInner1 = new Inner1(); objInner1.innerMethod1(); } class Inner1 { public void innerMethod1() { System.out.println("This is Inner Method1"); } } }
Output
This is Inner Method1