How does java implement inner class closures?
- by thecoop
In Java an anonymous inner class can refer to variables in it's local scope:
public class A {
public void method() {
final int i = 0;
doStuff(new Action() {
public void doAction() {
Console.printf(i); // or whatever
}
});
}
}
My question is how is this actually implemented? How does i get to the anonymous inner doAction implementation, and why does it have to be final?