interface A { public void print(); } public class Test { public static void main(String[] args) { fun(new A() { public void print() { System.out.println("B"); } }); } public static void fun(A a) { a.print(); } }