I cannot access var variable from inner class method. but java is accessing to class variable instead of local variable. How can I access to local variable instead of class variable from inner class method ?
class Foo {
void test() {
int var = 3;
class Inner {
int var = 1;
void print_var_of_test() {
System.out.println(var); // this line prints 1 why ?
// I want this line to print var of test (3) function.
}
}
}
}
print_var_of_test(int var)