Skip to main content
PreparationZone Logo
PrepZone

Intermediate Operations & flatMap

filter, map, flatMap, takeWhile — with a hands-on flattening kata.

Pass checkpoint below

Read these first

Intermediate operations

Java
public class Example {
    public static void main(String[] args) {
        .filter(predicate)
            .map(function)
            .flatMap(function)
            .distinct()
            .sorted() / .sorted(comparator)
            .limit(n) / .skip(n)
            .takeWhile(predicate)    // Java 9+
            .dropWhile(predicate)
            .peek(consumer)          // debugging only
            .mapToInt(f) / .boxed()
    }
}

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 1 section

  • map vs flatMap

Test yourself

Answer these before moving on — recall is what makes it stick.