I know if I use:
double data[][] = new double[n][];
// fill the array
DoubleStream stream = Arrays.stream(data).flatMapToDouble(Arrays::stream);
int max = stream.max().getAsDouble();
DoubleStream stream = Arrays.stream(data).flatMapToDouble(Arrays::stream);
int min = stream.min().getAsDouble();
i will get the minimum and maximum value that the stream has, like double.
However, I can’t understand for my whole life how to turn it into a “Supplier”. So
Supplier<Stream> stream = (Supplier<Stream>) Arrays.stream(data).flatMapToDouble(Arrays::stream);
double max = stream.max().getAsDouble();
double min = stream.min().getAsDouble();
Supplier<DoubleStream>
ether does not work, but ether does not work.
I managed to get it to work with
Supplier<DoubleStream> stream = () -> Arrays.stream(t).flatMapToDouble(Arrays::stream);
OptionalDouble max = stream.get().max();
OptionalDouble min = stream.get().min();
but why did the values in the stream become OptionDouble?
source
share