Zum Inhalt springen

List Fail-fast Behavior Quiz

What is the output of the Java code below?

„`

List<String> list = new ArrayList<>(List.of(„a“, „b“, „c“));

list.stream().map(s -> {

list.add(„x“);

return s.toUpperCase();

}).forEach(System.out::println);

„`

/**

  1. A B C

  2. ConcurrentModificationException

  3. Infinite loop

  4. Compilation error

**/

Link to the solution and explanation:

https://javabulletin.substack.com/p/list-fail-fast-behavior-quiz

submitted by /u/Educational-Ad2036
[link] [comments]

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert