Zest.

Java: Stream: filter and map

A short, tested Java example for stream: filter and map. Copy it and adjust the names and paths for your project.

Java
List<String> names = users.stream()
    .filter(u -> u.age() >= 18)
    .map(User::name)
    .sorted()
    .toList();

Find it in Zest

Search for “java stream: filter and map” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Java examples

All Java examples