the output is
foo
foo
but I was expecting it to be
foo
bar
foo
I do not under stand why the inner class does not work
class Test {
private String foo = "foo";
public void method() {
System.out.println(foo);
new Object() {
public void bar() {
foo = "barr";
System.out.println(foo); //not work
}
};
System.out.println(foo);
}
}
public class Main {
public static void main(String[] args){
Test t=new Test();
t.method();
}
}