K
K
Kastian2018-05-17 20:59:41
Java
Kastian, 2018-05-17 20:59:41

How to leave stream conditionally?

How to interrupt stream processing when a certain condition is reached? For example - to calculate the sum of elements, up to the first encountered zero?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-05-17
@iSmoke

Use takeWhile .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question