local class in Java

A local class has access to the members of its enclosing class. 
In addition, a local class has access to local variables. However, a local class can only access local variables that are declared final. When a local class accesses a local variable or parameter of the enclosing block, it captures that variable or parameter. 
However, starting in Java SE 8, a local class can access local variables and parameters of the enclosing block that are final or effectively final. A variable or parameter whose value is never changed after it is initialized is effectively final. 
Starting in Java SE 8, if you declare the local class in a method, it can access the method's parameters. 
<pre><code>
public class Class{
    public static void main(String []args){
        int j = 2;
        for (int i = 0; i< 5; i++) {
            class LocalClass {
                void say(int i) {
                    System.out.println(i*j);
                }
            }
            LocalClass local = new LocalClass();
            local.say(i);
        }
    }
}
</code></pre>
The inner class object cannot use the local variables of the method the inner class is in. Why not?
Think about it. The local variables of the method live on the stack, and exist only for the lifetime of the method. You already know that the scope of a local variable is limited to the method the variable is declared in. When the method ends, the stack frame is blown away and the variable is history. But even after the method completes, the inner class object created within it might still be alive on the heap if, for example, a reference to it was passed into some other code and then stored in an instance variable. Because the local variables aren't guaranteed to be alive as long as the method-local inner class object, the inner class object can't use them. Unless the local variables are marked final !
About modifiers within a method: the same rules apply to method-local inner classes as to local variable declarations. You can't, for example, mark a method-local inner class public , private , protected , static , transient , and the like.