The problem with the compilation error is that the subject did not pay too much attention. This can be easily checked. You can see the red area of the error report, which is the second parameter of the applyToEither method. Then check it applyToEither Parameter format of method
public <U> CompletableFuture<U> applyToEither(
CompletionStage<? extends T> other, Function<? super T, U> fn) {
return orApplyStage(null, other, fn);
}
The second parameter is a Function. What Function requires is to return a result based on a parameter. However, the question clearly states that there are no parameters. It is written as a Supplier. Of course, the parameter type is not Meet the requirements of method applyToEither
The problem with the compilation error is that the subject did not pay too much attention. This can be easily checked.
You can see the red area of the error report, which is the second parameter of the
applyToEither
method. Then check itapplyToEither
Parameter format of methodThe second parameter is a
Function
. WhatFunction
requires is to return a result based on a parameter. However, the question clearly states that there are no parameters. It is written as aSupplier
. Of course, the parameter type is not Meet the requirements of methodapplyToEither