::
.
import java.util.function.UnaryOperator;
import java.math.BigInteger;
// Methods compatible with a functional interface
class FunctionalFactorial {
public static BigInteger factorial(BigInteger i) {
if (i.equals(BigInteger.ZERO))
return BigInteger.ONE;
else
return i.multiply(factorial(i.subtract(BigInteger.ONE)));
}
public BigInteger instanceFactorial(BigInteger n) {
return factorial(n);
}
// Prints 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
public static void main(String args[]) {
UnaryOperator<BigInteger> f;
f = FunctionalFactorial::factorial;
System.out.println(f.apply(new BigInteger("100")));
f = new FunctionalFactorial()::instanceFactorial;
System.out.println(f.apply(new BigInteger("100")));
}
}