You can't. It can't be instantiated. But you can pass method references or lambdas of it's methods (although this example is somewhat contrived and not of much use).
double dmax = getMaximum(Math::max, 20., 40.);
int imax = getMaximum(Math::max, 14, 80);
System.out.println(dmax);
System.out.println(imax);
Prints
40.0
80
The method
public static <T> T getMaximum(BinaryOperator<T> op, T a, T b) {
return op.apply(a,b);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…