Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 685 Bytes

File metadata and controls

32 lines (24 loc) · 685 Bytes

Drop While:

It skips elements from the beginning of a stream as long as a given condition is true. Once the condition becomes false, it stops dropping elements and processes the rest of the stream normally.

        List<Integer> dropWhile = Stream.of(2, 4, 6, 8, 9, 10, 11, 12)
                .dropWhile(n -> n % 2 == 0)
                .collect(Collectors.toList());

        System.out.println("dropWhile = " + dropWhile);

Output:

[9, 10, 11, 12]

Previous: I Take While

Next: K Map Multi