List<String> result = lines.stream()
.filter(line -> "theLineIWant".equals(line))
.collect(Collectors.toList());
items.stream()
.filter(s->s.contains("B"))
.forEach(System.out::println);
User user1 = new User("James", "Gosling", 63);
User user2 = new User("Ken", "Thompson", 75);
User user3 = new User("Richard", "Stallman", 65);
List<User> userList = Arrays.asList(user1, user2, user3);
userList.stream().filter(user -> (user.getSurname().contains("a") && (user.getAge().equals(65))) ).collect(Collectors.toList()).forEach(System.out::println);
List<Customer> charlesWithMoreThan100Points = customers
.stream()
.filter(c -> c.getPoints() > 100 && c.getName().startsWith("Charles"))
.collect(Collectors.toList());
assertThat(charlesWithMoreThan100Points).hasSize(1);
assertThat(charlesWithMoreThan100Points).contains(charles);
Copy