Java 8 Functional Interfaces Java Java API
java.util.function.BinaryOperator
static <T> BinaryOperator<T> minBy(Comparator<? super T> comparator)
Returns a BinaryOperator which returns the lesser of two elements according to the specified Comparator.
BinaryOperator
Comparator
package com.logicbig.example.binaryoperator;import java.util.Comparator;import java.util.function.BinaryOperator;public class MinByExample { public static void main(String... args) { BinaryOperator<String> maxLengthString = BinaryOperator.minBy( Comparator.comparingInt(String::length)); String s = maxLengthString.apply("two", "three"); System.out.println(s); }}
two