Get a Slice of a Stream

suggest change

Example: Get a Stream of 30 elements, the 21st through 50th elements of a collection (1-based positions).

final long n = 20L; // the number of elements to skip
final long maxSize = 30L; // the number of elements the stream should be limited to
final Stream<T> slice = collection.stream().skip(n).limit(maxSize);

Notes:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents