Hi Everyone, Welcome come back to the tutorial. In this tutorial we will talk about functional interfaces.
We touched on this topic a bit in the previous tutorial. Lets dig in further and discuss more in
this tutorial. Function interfaces are something which are present in Java since JDK 1.0 and
those were referred as Single Abstract Method Interfaces (SAM).
The concepts are the same but those are categorized into a new modernized category which is called functional
interfaces.
As per the Java documentation the definition of functional interfaces is that any interface that has exactly
one abstract method.
Those are categorized as functional interfaces.
We have seen this annotation called our @Functionalinterface which got introduced in Java 8.
And all the interfaces which has one abstract method are annotated with @Functionalinterface.
This is an optional annotation but it does validate
the interfaces that are annotated with this @Functionalinterface to
make sure that the interfaces are not breaking the contract meaning it mandates the interface to have
only one abstract method. Lets talk about
the new functional interfaces that got introduced as part of this Java8.
The four primary interfaces are Consumer, Predicate, Function and Supplier. And each and every functional
interfaces have their own extensions.
Such as for consumers there is a BiConsumer, For Predicate
there is a BiPredicate, For Function there is BiFunction ,UnaryOperator and BinaryOperator.
You might be wondering.
I don't use any of these interfaces in my current project but still my application works like a charm.
Why do I have to learn these interfaces right?
The idea of this course is to give you the exposure to these new concepts and there are a lot of enhancements
that are made to the collections such as a list, map, set that uses these interfaces which is going to
make your development really really faster.
Don't worry if this is too much information to take at the moment I'll be explaining you all the new
interfaces by coding in the future tutorials. With this we came to the end of this tutorial.
Thank you for watching.