Lambda Expression in JAVA--Part 1
Hey, hello folks. How's the thing is going? Hope you guy's are doing well in your life,if not then don't worry all will be good soon. So my name is "Sumit Srivastava" and I am MCA passout of 2019 batch.
This is my first ever Technical Blog which i am writting to share some concept learnings on JAVA. So today i am taking a very important feature of JAVA 8. Here we go.
Lambda Expression
Lambda Expression
What is Lambda Expression?
It is one of the most important feature of java which is introduced in Java SE8. It is used to provide a short and clear way to represent one method interface by using expression. Its a block of code similar to function.
Syntax:
parameter -> expression
Java lambda expression syntax consisted of three components:-
- Argument-list (It can be empty/non-empty)
- Arrow-token (It is basically act as a bridge between Argument list and expression)
- Body ( We write expressions, statements, for lambda expression,gives implementation of functional interface)
Where to Use?
It is useful in Collection library and helps to iterate and extract collection data. Compiler treated it as a method,so it does'nt provide any .class file for this.
It is used to provide implementation of a interface, i.e Functional Interface, so we do not need to write the method again for the implementation purpose,we can use lambda expression and gives implementaion of that method. Therefore it save some line of codes as well. So obviously if it is saving line of code so it is also saving our time also to right that,right??
For providing implementation we use a block of code as an expression in syntax of lambda expression.
So, now the question is,what is functional interface ?




Comments
Post a Comment