Lambda: BiFunction takes two arguments and produces a result of a third type

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.

Code
BiFunction<String, Integer, String> repeat = (s, n) -> s.repeat(n);
System.out.println(repeat.apply("ab", 3));
Output
ababab
Advertisement
More in JAVA

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

© Java Coding Hub · About · Contact · Privacy · Terms