I as trying out some Spring reactive code and following is relevant piece of code
Supplier<Stream<Long>> longStreamSupplier = ()
-> LongStream.iterate(0,
nextLong -> nextLong + 1).boxed();
Flux<Long> fooIds = Flux.fromStream(longStreamSupplier);
Last line above gives compilation error in Intellj IDE saying there is not method which accepts the type.
However if i convert it to following :
Flux<Long> fooIds = Flux.fromStream(() -> LongStream
.iterate(0, nextLong -> nextLong + 1)
.boxed());
This works fine. Why it cant accept a reference variable pointing to the same lambda expression i am passing in second piece of code?