The following snippet shows how you can collect a stream into an existing collection using Collectors.toCollection
:
stream.collect(Collectors.toCollection(() -> existingCollection));
You may also be interested in reading my previous post about collecting a stream into an unmodifiable collection.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.