BiConsumer represents an operation that accepts two input arguments and returns no result.
The following example shows how to use BiConsumer
.
import java.util.function.BiConsumer; //from ww w.j av a 2s . com public class Main { public static void main(String[] args) { BiConsumer<String, String> biConsumer = (x, y) -> { System.out.println(x); System.out.println(y); }; biConsumer.accept("java2s.com", " tutorials"); } }
The code above generates the following result.
biConsumer.accept("java2s.com", " tutorials");
biConsumer.andThen(biConsumer).accept("java2s.com", " tutorial");