Filter Stream With List Java Code Example

Snippet 1

  items.stream()
 .filter(s->s.contains("B"))
 .forEach(System.out::println); 

Snippet 2

  List result = lines.stream()               
                .filter(line -> "theLineIWant".equals(line))
                .collect(Collectors.toList()); 

Copyright © Code Fetcher 2020

 

 

Published

Leave a comment

Your email address will not be published. Required fields are marked *