By Janice J. Heiss on Aug 15, 2013
A new article, now up on otn/java, by Deepak Vohra, titled “Trying Out Lambda Expressions in the Eclipse IDE,” demonstrates how to take advantage of lambda expressions in Java SE 8 using the Eclipse IDE and virtual extension methods.
Vohra begins with the basics:
“Lambda expressions, also called closures, are a short-form replacement for anonymous classes. Lambda expressions simplify the use of interfaces that declare a single abstract method, which are also called functional interfaces. In Java SE 7, a single method interface can be implemented with one of the following options.
* Create a class that implements the interface.
* Create an anonymous class.”
Vohra explains that while lambda expressions can be used to implement a functional interface without creating a class or an anonymous class, they can be used only with interfaces that declare a single method.
Benefits of lambda expressions include:
* Concise syntax
* Method references and constructor references
* Reduced runtime overhead compared to anonymous classes
Vohra gets under the hood to explain the basics of lambda syntax, along with the nature of functional interfaces and target types, offering copious examples. All in all, the article offers a first-rate primer on how to make use of lambda expressions and virtual extension methods using the Eclipse IDE.
Check out the story here.