The rules for determining the scope of a local class largely coincide with the rules for determining the scope of a variable, i.e. limited to the closing block.
Similarly, you cannot access the iob variable from main , you cannot access the local Inner class from main .
Outside of the closing block, there is no difference between a local class and an anonymous class. Access to them is also impossible. The difference is that in the closing block access to the local class can be obtained by name, it is especially useful if you need to access it several times, for example. to create multiple instances.
The only way to interact with a local / anonymous class outside the closing block is through any superclass or interface implemented by the class in question.
source share