• Post Reply Bookmark Topic Watch Topic
  • New Topic

Practical usage of Lambda

 
Nandhini Sridharan
Ranch Hand
Posts: 58
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going over the new features of Java 8. One of them would be Lambda expressions.

I know with Lambda, we can pass functions as method parameters. With respect to mathematical operations, we can pass the function as method parameter. But in what way, does this functionality majorly improves the java capability? Meaning, how are we achieving the most of this functionality with respect to application development?

Can someone throw light on this one?

Thanks
 
Nandhini Sridharan
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to answer my question by myself

Thanks to the post http://www.coderanch.com/t/646488/java/java/Core-Java-benefits-lambda-expressions

The advantages of Lambda with respect to Java programming is that

1. It aids less typing (Without beating around the bush, just expresses the actual calculation being made and fading out unnecessary syntax information)
2. The above statement also serves in another way that the programmer is just interested in what is being done (the actual business logic) than the decorating code like public static all those blah blah blah
3. When we pass function as method parameter, the method really need to know what is the result of that function rather than how the result has been achieved
 
Junilu Lacar
Sheriff
Posts: 9932
103
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book "Java 8 in Action" has lots of examples of how lambdas can help you write simpler and more elegant programs that are closer to the functional style of programming. To say that lambdas help reduce typing is very superficial, IMO. That you have to type less is just a natural consequence of being able to write more concise code. The conciseness and clarity of the code that you can write with lambdas is what is really important along with the shift to functional programming.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!