Class C's method foo declares and instantiates a local class L:
// Assume JDK 8
class C {
void foo(String p) {
int i = 0;
final double f = 3.0;
// local class L
class L {
void bar() {
/*
what can be accessed here?
*/
}
}
// change i and x
i = p.length();
x++;
// create L's instance and call bar()
L l = new L();
l.bar();
} // end foo()
private int x = 1;
} // end class C
Assume that above code is written for JDK 8 (Java-8). Select all the fields or variables that can be accessed inside method bar() of local class L: