class Test { public interface I { int m(); } public interface I1 { int m(int y); } { boolean flag = true; I i = flag ? (() -> 123) : (() -> 222); I i1 = flag ? (() -> {}) : (() -> 222); Object i2 = flag ? (() -> 42) : (() -> 222); I i3 = flag ? ((x) -> 42) : (() -> 222); I i4 = flag ? (() -> 42) : new I() { @Override public int m() { return 0; } }; } } class Test1 { interface I { V m(T t); } static void bar(I ii, I ik){} { bar(s -> s.equals("") ? 0 : 1, i -> ""); } }