home

Nested Classes

Inner Classes

Inner Class Instance Initialization

class Foo {
    private Foo(){}
    class Bar {
        private Bar(){}
        private void bar(){
            System.out.println("bar");
        }
    }
    public static void main(String[] args) {
        Foo foo = new Foo();
        Bar bar = foo.new Bar();
        bar.bar(); // bar
    }
}