Interesting puzzle there. Unless you make B
a static class, the only way you can instantiate A
is by passing null
to the constructor. Otherwise you would have to get an instance of B
, which can only be instantiated from an instance of A
, which requires an instance of B
for construction...
The null
solution would look like this:
anotherMethod(new A(new A(null).new B(5)));