BiFunction<T, U, R> generalizes Function to two input types, letting a single lambda combine two values of possibly different types into a result of a third type.
BiFunction<String, Integer, String> repeat = (s, n) -> s.repeat(n);
System.out.println(repeat.apply("ab", 3));
ababab
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-09-27