Witscale Test Center

4.6 Local inner class > 4.6.1 Declaration rules for method-local inner class


4.6.1 Declaration rules for method-local inner class

Any declaration within a method body is local to the method body and is not a member of the class. For example, a variable declared within method is local to a method and is accessible only within the method. Similarly, an inner class declared within method body is accessible only within that method. Therefore the access modifiers public, private, protected do not make any sense in the context of method-local class and hence should never be applied to it. Method-local cannot be static as it is accessible only within a method.