0% found this document useful (0 votes)
8 views1 page

Java Class

Functional interfaces in Java are designed for functional programming, featuring exactly one abstract method, which allows for the use of lambda expressions and method references. They enhance code readability and can include multiple default and static methods. To use a functional interface, one must create an interface with a single abstract method and implement it using lambda expressions or method references.

Uploaded by

mahesh2635583
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Java Class

Functional interfaces in Java are designed for functional programming, featuring exactly one abstract method, which allows for the use of lambda expressions and method references. They enhance code readability and can include multiple default and static methods. To use a functional interface, one must create an interface with a single abstract method and implement it using lambda expressions or method references.

Uploaded by

mahesh2635583
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Functional interface→

Functional interface are powerful tool in Java for implementing functional programming
techniques
It is an interface with exactly 1 abstract method, enabling a to be used with lamda
expression , and method references.

Keypoints→
1st)--> it must have only one abstract method that is why it also called single abstract
method interface ( SAM )

2)--> it allow lemda expression to making the code redable

3)--> it can also be implemented using method references for simplifying the code

4)--> they can also have multiple default and static method

How to use functional interface

1)--> create an interface with exactly one abstract method

2)--> use lemda expression to provide the implementation of the abstract method

3)--> use method references to provide the implementation of the abstract method

Eg-

@FunctionalInterface
interface MyName {
void printName();
}

public class Main {


public static void main(String[] args) {
// Lambda expression
MyName name = () -> System.out.println("My name is Ankit");

// Calling the method


name.printName();
}
}

Output: My name is Ankit

You might also like