Example :
public class Main { public static void main(String[] args) throws IOException { MockData.getPeople() .stream() .forEach(System.out::println); List<String> namesList = Arrays.asList("Tyson","Justin","Martin"); namesList.stream().forEach(System.out::println); } }
public class Main { public static void main(String[] args) throws IOException { List<String> namesList = Arrays.asList("Tyson","Justin","Martin"); namesList = namesList.stream().filter(x -> x.startsWith("T")).collect(Collectors.toList()); namesList.stream().forEach(System.out::println); } }