Java8features Functionalinterface 1713014023
Java8features Functionalinterface 1713014023
Java
Functional
interface
Functional Interfaces
@techwithvishalraj
@FunctionalInterface
interface Welcome{
void hello(); // abstract method
// It can contain any number of Object class methods.
int hashCode();
String toString();
boolean equals(Object object);
}
@FunctionalInterface
interface MyFunctionalInterface {
void abstractMethod();
default void defaultMethod() {
System.out.println("Default method implementation");
}
static void staticMethod() {
System.out.println("Static method implementation");
}
}
interface MyInterface {
default void defaultMethod(){
System.out.println("Default method implementation");
}
int hashCode();
}
@FunctionalInterface
interface MyFunctionalInterface extends MyInterface {
void abstractMethod();
}
Interface Description
Consumer<T> Interface
It contains an abstract accept() method and a default andThen() method.
BiConsumer<T,U> Interface
It contains an abstract accept() method and a default andThen() method.
Supplier<T> Interface
It has a single abstract method get().
Predicate<T> Interface
it contains an abstract test() method and some default & static
methods too.
Function<T,R> Interface
it contains an abstract apply() method and some default & static
methods too.
BiFunction<T,U,R> Interface
it contains an abstract apply() method and default andThen() method.
Thank
you!
vishal-bramhankar
techwithvishalraj
Vishall0317