Split a list into sublists based on a condition with Stream api : <p>I have a specific question. There are some similar questions but these are either with Python, not with Java, or the requirements are different even if the question sounds similar. </p>

<p>I have a list of values.</p>

<pre><code>List1 = {10, -2, 23, 5, -11, 287, 5, -99}
</code></pre>

<p>At the end of the day, I would like to split lists based on their values. I mean if the value is bigger than zero, it will be stay in the original list and the corresponding index in the negative values list will be set zero. If the value is smaller than zero, it will go to the negative values list and the negative values in the original list will be replaced with zero.</p>

<p>The resulting lists should be like that;</p>

<pre><code>List1 = {10, 0, 23, 5, 0, 287, 5, 0}
List2 = {0, -2, 0, 0, -11, 0, 0, -99}
</code></pre>

<p>Is there any way to solve this with Stream api in Java?</p>
