- limit operation on stream returns a new stream whose item count is limited with respect to the original stream.
int stream one to three
Stream<Integer> oneToThree = Stream.of(1, 2, 3);
Stream<Integer> limitedStream = oneToThree.limit(2);
log.info("verifying that oneToThree integer stream limited by 2 returns a stream with 2 items: ");
limitedStream.forEach(number -> log.info(number.toString()));