Java Learner logo
← Back to all exercises

Streams

Chaining Stream operations

Write the exact string printed when this stream pipeline executes.

Streams

Chaining Stream operations

IntermediateAwaiting attempt

Write the exact string printed when this stream pipeline executes.

import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        List<String> features = List.of("records", "switch", "pattern", "sealed", "lambda");
        String joined = features.stream()
                .filter(word -> word.contains("a"))
                .map(String::toUpperCase)
                .sorted()
                .collect(Collectors.joining(" | "));

        System.out.println(joined);
    }
}