I have List of items where on each item I need to create some calculation. Each calculation is built by the preceding element.
So for example:
List<Object> Users=new ArrayList<>();
users.stream().filter(element->calculateSomething(<need-prev-element-input>).findFirst();
The calculateSomething will return true/false depends on the prev element calculation result in the stream
Any idea how can I do that?
Streams are not designed to be able to do any operation like this. You might be able to hack something together to do that, but it'll be awful; you should go back to using normal loops instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With