Java 8 Functional Interfaces Java Java API
Interface:
java.util.function.BinaryOperator
Method:
static <T> BinaryOperator<T> minBy(Comparator<? super T> comparator)
Returns a BinaryOperator which returns the lesser of two elements according to the specified Comparator .
Examples
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); } }
Outputtwo
|