Method-Local Inner Classes


  • A method-local inner class is defined within a method of the enclosing class.
  • For the inner class to be used, you must instantiate it, and that instantiation must happen within the same method, but after the class definition code.
  • A method-local inner class cannot use variables declared within the method (including parameters) unless those variables are marked final.

  • The only modifiers you can apply to a method-local inner class are abstract and final. (Never both at the same time, though.)