#5 Operation Order in the Stream API

Companies:
Alfa-Bank
Themes:
JavaStreams & LambdasCode Review

What will be printed to the screen?

public class Main {
    public static void main(String[] args) {
        List<Integer> x1 = List.of(1, 2, 3);
        List<Integer> x2 = List.of(4, 5, 6);
        List<Integer> x3 = List.of();

        Stream.of(x1, x2, x3)
            .map(x -> x+1)
            .flatMap(Collection::stream)
            .forEach(System.out.print);
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in