interface Test {
public void test();
}
public class TestMain {
private String h = "AAA";
public static void main(String[] args) {
TestMain t = new TestMain();
}
public TestMain() {
Test t = new Test() {
public void test() {
System.out.println( h );
}
};
t.test();
}
}
This source works well.
But I think the variable "h" should be inaccessible from an anonymous class. I need to know why this works.
Thanks for your help in advance!
source
share