Java Stream filter data after a condition
import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { /* w w w. ja v a 2 s . com*/ public static void main(String[] args){ List<String> myLangs = Arrays.asList("CSS","HTML","Java"); System.out.println("Collection Data: " + myLangs); Stream.of("CSS","HTML","Java") .takeWhile(s -> !s.contains("Java")) .forEach(System.out::println); Stream.of("CSS","HTML","Java") .dropWhile(s -> !s.contains("Java")) .forEach(System.out::println); } }