Default Methods


Idioms and Techniques

Design Rationale

Advanced Questions

Why is there no shorthand syntax for invoking a lambda?

A lambda expression provides a concise, shorthand syntax for implementing the single abstract method of a functional interface. Why isn’t there a corresponding shorthand for invoking the lambda? For example, the default implementation (simplified for clarity) of Iterable.forEach is as follows:

default void forEach(Consumer<T> action) { for (T t : this) { action.accept(t); } } […]