In "Optional" source code, I found this function:
public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
if (value != null) {
return value;
} else {
throw exceptionSupplier.get();
}
}
My question is if I change the function to this, it looks like working same
public <X extends Throwable> T orElseThrow(Supplier<X> exceptionSupplier) throws X {
if (value != null) {
return value;
} else {
throw exceptionSupplier.get();
}
}
Anyone know the reason?