Java Streams: Limit and Skip
Truncating a stream
If you go
user.stream().count();
you’re going to retrieve the long
-valued number of items in the stream/list.
Working with the stream size may be useful and there are two intermediate operations, in particular, that I found easy to use and handy.