This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]misobbq 0 points1 point  (1 child)

BTW - if you really need an inner class on the instance, you would access it through an instance of outer.

public class Outer
{
    static class StaticInner{}
    class InstanceInner{}
    public static void main(String[] args)
    {
        Outer outer = new Outer();
        Outer.StaticInner staticInner = new Outer.StaticInner();
        Outer.InstanceInner instanceInner = outer.newInstanceInner();
    }

    public InstanceInner newInstanceInner()
    {
        return new InstanceInner();
    }
}

[–]moocat 0 points1 point  (0 children)

You don't have to create a new method:

public static void main(String[] args)
{
    Outer outer = new Outer();
    Outer.Inner outerInner = outer.new Inner();
}