- Finding 10 people whos age is less than 18
@Test public void declarativeApproachUsingStreams() throws Exception { List<Person> people = MockData.getPeople(); people.stream() .filter(p -> p.getAge() <= 18) .limit(10) .collect(Collectors.toList()) .forEach(System.out::println); }