Function functional Interface



java.util.function.Function<T, R> interface has one abstract method named apply. it takes one generic type object as argument and returns another object of generic type R.
This functional interface is used when you need to define a lambda expression that maps information from one object called input to
another output object.

Example
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
public class FunctionFlight {
    public static void main(String[] args) {
        List<String> words = Arrays.asList("Good","Morning","Universe");
        Function<String,Integer> function = (s)->s.length();
        List<Integer> lengts = map(words, function);
        System.out.println(lengts);
    }
   
    private static <T,R> List<R> map(List<T> list, Function<T,R> function){
        List<R> result = new ArrayList<>();
        for(T t: list) {
            result.add(function.apply(t));
        }
        return result;
    }
}

Output
[4, 7, 8]