Can we collect two lists from Java 8 streams?

user10179187 :

Consider I have a list with two types of data,one valid and the other invalid.

If I starting filter through this list, can i collect two lists at the end?

Stephen C :

Another suggestion: filter using a lambda that adds the elements that you want to filter out of the stream to a separate list.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=111808&siteId=1