Hi,
Can anybody please explain the working of the below code?not clear with the syntax " (new Bar() {}).go();"
public class Foo {
Foo() {System.out.print("foo");}
class Bar{
Bar() {System.out.print("bar");}
public void go() {System.out.print("hi");}
}
public static void main(
String[] args) {
Foo f = new Foo();
f.makeBar();
}
void makeBar() {
(new Bar() {}).go();
}
}
Thank you
Maya