Lambda expressions are one of the most attractive features of Java 8 release. Lambda expressions improve the Platform’s syntax and code redundancy by large.
What are Lambda Expressions?
Java 8 introduces Lambda Expressions, part of the Project Lambda Initiative.
The lambda expression is made of two parts the one on the left of the arrow symbol (->) listing its parameters and the one on the right containing its body. In this case the compiler automatically figures out that the lambda expression has the same signature of the only non implemented method of the Consumer interface (that for this reason is called a functional interface) and treat the first as it was an instance of the second, even if the generated bytecode could potentially be different.
Lambda expressions make the code much more readable.
Consider following snippet, it works:
numbers.forEach(value -> System.out.println(value));
For more about lambda expressions, read this.
Backporting Lambda Expressions to Java 7, Java 6, Java 5, Java 4
Lambda expressions are so effective that probably you’ve already using them in your development environment, but your production environment may not be running Java 8. So the chances are you are looking for backports and you did reach the right place.
Retrolambda is an open source project that brings Java 8’s Lambda expressions to Java 7, 6, 5. It makes this possible by taking your Java 8 compiled bytecode and transforms it so that it can run on older JVM runtimes. On the inside, it uses the Java agent to determine what bytecode LambdaMetafactory generates and saves it as class files. Then it replaces the invokedynamic instructions to instantiate those classes directly.
Retrolambda, however, doesn’t support serializable lambda expressions, and also doesn’t backport other Java 8 APIs.
We write latest and greatest in Tech Guides, Apple, iPhone, Tablets, Android, Open Source, Latest in Tech, subscribe to us @geeknizer OR on Facebook Fanpage, Google+.
loading...
loading...
Thanks for the insight!
loading...
loading...