Double-standard for inner class if it is non-static vs if it is static
posted 5 years ago
Enthuware explanation for an answer to a question:
As method inner is an instance method (ie. non-static method), si, ii, and fai are accessible in class Inner. Note that ai is not accessible. If method inner() were a static method, ii would have been inaccessible.
Here method inner is non-static and is able to access si, which is a static variable belonging to class TestClass. I cannot understand the logic for this.
On the other hand if method inner is static, it is notable to access ii, which is an instance variable belonging to an object of TestClass.
And why can't method inner access ai, the automatic variable? Would method inner be able to access ai if method inner was static?