Interface Name | Description | Abstract Method |
---|---|---|
Function<T, R> | Accepts one argument and produces a result. | R apply(T t) |
DoubleFunction<R> | Accepts a double-valued argument and produces a result. | R apply(double d) |
IntFunction<R> | Accepts a int-valued argument and produces a result. | R apply(int i) |
LongFunction<R> | Accepts a long-valued argument and produces a result. | R apply(long l) |
DoubleToIntFunction | Accepts a double-valued argument and produces an int-valued result. | int applyAsInt(double d) |
DoubleToLongFunction | Accepts a double-valued argument and produces a long-valued result. | long applyAsLong(double d) |
IntToDoubleFunction | Accepts a int-valued argument and produces an double-valued result. | double applyAsDouble(int i) |
IntToLongFunction | Accepts a int-valued argument and produces an long-valued result. | long applyAsLong(int i) |
LongToDoubleFunction | Accepts a long-valued argument and produces an double-valued result. | double applyAsDouble(long l) |
LongToIntFunction | Accepts a long-valued argument and produces an int-valued result. | int applyAsInt(long l) |
ToDoubleFunction<T> | Accepts a reference type and produces a double-valued result. | double applyAsDouble(T t) |
ToIntFunction<T> | Accepts a reference type and produces a int-valued result. | int applyAsInt(T t) |
ToLongFunction<T> | Accepts a reference type and produces a long-valued result. | long applyAsLong(T t) |
BiFunction<T,U,R> | Accepts two arguments and produces a result. | R apply(T t, U u) |
ToDoubleBiFunction<T, U> | Accepts two arguments and produces a double-valued result. | double applyAsDouble(T t, U u) |
ToIntBiFunction<T, U> | Accepts two arguments and produces a int-valued result. | int applyAsInt(T t, U u) |
ToLongBiFunction<T, U> | Accepts two arguments and produces a long-valued result. | long applyAsLong(T t, U u) |
Function functional interface has following methods:

Applicant Example using Function functional Interface
public class Applicant {
private String name;
private String email;
private int yearOfExperience;
private double qualificationScore;
public Applicant(String name, String email, int yearOfExperience, double qualificationScore) {
this.name = name;
this.email = email;
this.yearOfExperience = yearOfExperience;
this.qualificationScore = qualificationScore;
}
public int getYearOfExperience() {
return yearOfExperience;
}
public double getQualificationScore() {
return qualificationScore;
}
}
public class Main {
public static void main(String[] args) {
Applicant newApplicant = new Applicant("Alice", "alice@gmail.com", 4, 6.7);
Function<Applicant, Double> suitabilityCalculator = (Applicant applicant) ->{
double experienceFactor = 0.2;
double qualificationFactor = 0.8;
return (experienceFactor * applicant.getYearOfExperience()) + (qualificationFactor*applicant.getQualificationScore());
};
Double suitabilityScore = suitabilityCalculator.apply(newApplicant);
System.out.println("New Applicant's suitability score is: " + suitabilityScore);
}
}