str is out of scope in the UseOuter class' main method.
But why is it the scope of UseOuter's main that determines whether str is accessible to the anonymous class? str is available to Inner and isn't declared private. Therefore it seems to me that str ought also be available to all the subclasses of Inner.
Perhaps I should rather phrase my question like this: Can you (or someone else) provide a good reason for why the creators of Java chose to make non-private variables that are available in a given class unavaible to it's subclasses?
Create a final object of Outer. Use that object to create a new Inner class and then also use the same Outer object to access the str String. The object has to be final because anonymous inner classes can only access final local variables.
Remember that str is not inherited by the Inner class or by the UseOuter class, so the variable str is not visible where the anonymous class is defined.