Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shubh2-0/functional-interface
An interface with exactly one abstract method is called Functional Interface. @FunctionalInterface annotation is added so that we can mark an interface as functional interface. It is not mandatory to use it, but it’s best practice to use it with functional interfaces to avoid addition of extra methods accidentally. If the interface is annotated wit
https://github.com/shubh2-0/functional-interface
annotation exceptions functional-programming interface java jvm lamda-functions
Last synced: 3 months ago
JSON representation
An interface with exactly one abstract method is called Functional Interface. @FunctionalInterface annotation is added so that we can mark an interface as functional interface. It is not mandatory to use it, but it’s best practice to use it with functional interfaces to avoid addition of extra methods accidentally. If the interface is annotated wit
- Host: GitHub
- URL: https://github.com/shubh2-0/functional-interface
- Owner: Shubh2-0
- Created: 2023-02-26T22:31:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-26T22:38:44.000Z (almost 2 years ago)
- Last Synced: 2024-05-01T13:47:21.294Z (9 months ago)
- Topics: annotation, exceptions, functional-programming, interface, java, jvm, lamda-functions
- Language: Java
- Homepage:
- Size: 14.6 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Functional-Interface
An Interface that contains exactly one abstract method is known as functional interface. It can have any number of default, static methods but can contain only one abstract method. It can also declare methods of object class.
Functional Interface is also known as Single Abstract Method Interfaces or SAM Interfaces. It is a new feature in Java, which helps to achieve functional programming approach.
# Example
@FunctionalInterface
interface sayable{
void say(String msg);
}public class FunctionalInterfaceExample implements sayable{
public void say(String msg){
System.out.println(msg);
}
public static void main(String[] args) {
FunctionalInterfaceExample fie = new FunctionalInterfaceExample();
fie.say("Hello there");
}
}# Output:
Hello there