A local variable or method parameter must be declared final if it is to be used by an inner class declared inside a method. : final « Modifiers « SCJP






public class MainClass {
  public static void main(String[] argv) {
    int i = 0;

    class MyClass {
      void m() {

        System.out.println(i);
      }
    }

  }
}
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Cannot refer to a non-final variable i inside an inner class defined in a different method

	at MainClass.main(MainClass.java:8)








3.6.final
3.6.1.final variables
3.6.2.A final class cannot be subclassed.
3.6.3.If a final variable references to an object, the reference must stay the same(not the object)
3.6.4.A final method may not be overridden
3.6.5.final local variable indicates that the value of a variable cannot be changed once assigned a value.
3.6.6.Local variables and method parameters may also be declared as final to enable them to be accessed by local inner classes.
3.6.7.final method may not be overridden.
3.6.8.The final keyword means that the field cannot be changed once initialized.
3.6.9.A final variable can't have its value changed after initialization.
3.6.10.A local variable or method parameter must be declared final if it is to be used by an inner class declared inside a method.