Check out our courses:
Enterprise Java Spring Microservices:
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development :
Coupon: TELUSKO20 (20% Discount)
For More Queries WhatsApp or Call on : +919008963671
Udemy Courses:
Spring:
Java:-
Java Spring:-
Java For Programmers:-
Python :
Git :
Docker :
website :
In this lecture, we are discussing functional interface:
what is functional Interface?
--functional interface is an interface with only one abstract method
The properties of a functional interface in Java are as follows:
Single Abstract Method: A functional interface has only one abstract method.
This method is the signature of the interface and defines the behaviour that will be implemented in the lambda expression or with simple class.
Functional Method: The abstract method of a functional interface is called the functional method.
It is the method that provides the functional behaviour of the interface.
Annotation: A functional interface is annotated with the annotation.
This annotation is optional, but it provides a compile-time check that the interface has only one abstract method.
Compatible with Lambda Expressions: A functional interface is compatible with lambda expressions.
A lambda expression is a concise way of implementing the functional method of a functional interface.
(This will discuss in next lecture of lambda expression).
Functional interfaces are a key component of functional programming in Java,
and they are used extensively in the Java 8 Streams API and other Java libraries.
Example
class Main{
public static void main(String []args){
A obj = new B();
obj.show();
//another way to implement functional interface
A obj1 = new A(){
public void show(){
System.out.println("Hello");
}
};
obj1.show();
}
}
//one way to implement functional interface
class B implements A{
public void show(){
System.out.println("Hello");
}
}
//specify it is functional interface
//we use this annotation to specify it is functional interface
interface A{
void show();
//void run(); //this will give error as it is a functional interface you cannot write two abstract method in this
}
Github repo :
Java:-
Spring:-
More Learning :
Java :-
Python :-
Django :-
JavaScript :-
Node JS :-
Rest Api :-
Servlet :-
Spring Framework :-
Design Patterns in Java :-
Docker :-
Blockchain Tutorial :-
Corda Tutorial:-
Hyperledger Fabric :-
NoSQL Tutorial :-
Mysql Tutorial :-
Data Structures using Java :-
Git Tutorial :-
Donation:
PayPal Id : navinreddy20
Смотрите видео #72 Functional Interface New in Java онлайн без регистрации, длительностью 03 минут 34 секунд в хорошем hd качестве. Это видео добавил пользователь Telusko 19 Январь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 92 тысяч раз и оно понравилось 97 людям.