Try to think of it this way.
Ifc i = new Ifc() { /* class body statements */ };
is not instantiating the interface Ifc, but is instantianting a class that implements the interface.
You can see this if you look at the class objects for the interface, and the class you instantiated:
System.out.println(Ifc.class.toString());
System.out.println(i.getClass().toString());
Think of it as shorthand for
final class AClass implements Ifc {
/* class body statements with no constructor*/
};
Ifc i = new AClass();
You are instantiating class the defined by the body statements that implements the interface, not the interface itself.
You may find it helpful to consider this example of an anonymous class that extends another class, instead of implementing an interface.
abstract class AClass {
protected int x;
AClass(int i) { this.x = i;}
abstract void m() ;
}
class Junk7 {
public static void main(
String[] args) {
AClass a = new AClass(7) {
void m() {
System.out.println(x); // Just so we can see it do something
}
};
a.m();
System.out.println(AClass.class.toString());
System.out.println(a.getClass().toString());
}
}
Clearly, refers to an instance of an anonymous class (probably the class named Junk7$1), not to an instance of the abstract class AClass.