Character[] ca = {'b', 'c', 'a', 'e', 'd'};
List<Character> l = Arrays.asList(ca);
l.parallelStream().peek(System.out::print).forEachOrdered(System.out::print);
The correct answer from the test is : The characters printed by peek may be in any order but the characters printed by forEachOrdered will always be in the same order as the original list i.e. bcaed. but I have run it with IntelliJ and one result that I got was cebbcdaaed.
Is my IDE going bonkers?
No, you are interpreting the results incorrectly. The output of peek and forEachOrdered is interspersed. Run the code without peek and then observe the output.
If you like our products and services, please help us by posting your review here.
Indeed it's bcaed.
I thought the result after running the code should be something like .....bcaed (where ..... is a combination of 'b', 'c', 'a', 'e', 'd').
You mean the result I got cebbcdaaed contains in fact the sequence bcaed but between the other characters from peek?