Feature of Java 8
1. Stream: is a sequence of elements supporting sequential and parallel aggregate operations.
1. Lambda Expression:is nothing but anonymous function and it applicable with functional interface(Lambda expression use with functional interface without functional interface no use of Lambda expression).
The main objective of Lambda Expression:
To bring benefits of functional programming into java
Note: only single argument method have paranthess is optional. but zero arg, and two, three and etc. arg then paranthess should be manadatory
Note: In Lambda Expressiong, Without curly braces we can not return keyword. Compiler will consider returned value automatically.
Once we write Lambda Expressions then I will discuss Functional Interface
2. Functional Interface: If any interface which contains single abstract method. it called functional Interface.
Within curly braces if we want to return some value compulsory we should use return statement.
Anonymous Inner class !=Lambda Expressions
If anonymous inner class implements an interface that contain single abstract method then only we can replace that anonymous inner class with Lambda expressions
Predicate:-Take some input and perform some conditional check and returns boolean value.
Function:-Take some input and perform some operation and return the result which is need not be boolean type.
Consumer:-Accept some input and perform required operation and not required to return anything.
Supplier:-just supply my required objects and it won't take and input.
No comments:
Post a Comment