posted 7 years ago
Hi, there are two ways of looking at that. From a purely practical perspective, you don't have to do as much typing. For example,
is less typing than
But I like to think about it more philosophically. The lambda syntax better expresses the intent of the programmer. When I have a task, then I think "when it is invoked, then call doWork 1000 times". I do not think that I want to create an anonymous class that implements the Runnable interface whose run method does ...". All that stuff with the anonymous class and the interface and the run method is just implementation detail. With the old way, the detail drowned out the important part. With lambda expressions, the unimportant part fades in the background, and you write and read the code that matters.
Cheers,
Cay