About Question enthuware.ocpjp.ii.v11.2.1801 :
Posted: Mon Jun 08, 2020 5:14 am
What will the following code print when compiled and run?
List<StringBuilder> messages = Arrays.asList(new StringBuilder(), new StringBuilder());
messages.stream().forEach(s->s.append("helloworld"));
messages.forEach(s->{
s.insert(5,","); System.out.println(s);
});
Your correct answer is
"helloworld
helloworld".
But this is wrong..
Q12 of Test 3.
List<StringBuilder> messages = Arrays.asList(new StringBuilder(), new StringBuilder());
messages.stream().forEach(s->s.append("helloworld"));
messages.forEach(s->{
s.insert(5,","); System.out.println(s);
});
Your correct answer is
"helloworld
helloworld".
But this is wrong..
Q12 of Test 3.