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