public class Foo { public void foo() { Predicate predicate = new Predicate() { @Override public boolean test(T t) { return false; } }; } private interface Predicate { boolean test(K t); } }