No enclosing instance of type Foo is accessible. Must qualify the allocation with an enclosing instance of type Foo (e.g. x.new A() where x is an instance of Foo).
You can get the error
No enclosing instance of type Foo is accessible. Must qualify the allocation with an enclosing instance of type Foo (e.g. x.new A() where x is an instance of Foo).
if you try to instantiate an inner class without an instance of the outer class.
@@@ check!
WRONG
class Foo
{
private class Bar
{
// stuff
}
}
class Baz
{
Foo.Bar aBar = new Foo.Bar(); // wrong!
}
WRONG
class Foo
{
private class Bar
{
// stuff
}
}
class Baz
{
Foo.Bar aBar = (new Foo).new Bar();
}