Access inner class from outsideTag(s): Language

public class TestIt {
    public static void main(String[] args) {
        Outer outer = new Outer();
        outer.new Inner().hello();
        /*
        output :
        Hello from Inner()
        */
    }
}

class Outer {
    public class Inner {
        public void hello(){
          System.out.println("Hello from Inner()");
        }
    }
}



If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2012
[ home ]