To refer from the inner class Inner to an instance of the framing class Outer use the following entry:

 Outer.this 

Is it possible to refer from the Inner class to an instance of the class framing the Outer class and at the same time not use the design of the ИмяКлассаОбрамляющегоОбрамляющийКласс.this ?

Is there a real use of such an architecture when a class contains inner classes, which in turn also contain inner classes?

  • The use of such a construction with multiple embedding of inner classes is not practical. All your tasks you can solve easier. Here I wrote a little about the internal, nested, local classes: habr.com/en/en/post/439648 - Vyacheslav Mischenko

1 answer 1

for this you need to use inheritance from the framing class, don’t know how practical it is, but it looks ugly

 class ИмяКлассаВложенногоВВложенныйКласс extends ИмяКлассаОбрамляющегоОбрамляющийКласс {ИмяКлассаОбрамляющегоОбрамляющийКласс sc = this;}