interface ITest{
public void setVal();
}
public class
Test {
private
String a;
void aMethod(){
final String b = " World";
ITest it = new ITest() {
public void setVal(){
a = "Hello" + b;
}};
it.setVal();
System.out.println(a);
}
public static void main(String[] args) {
Test t = new Test();
t.aMethod();
}
}
prints Hello World.
Please could somone explain .I thought that interface cannot be instantiated and the above code should give compiler error
Thanx in advance
Neha