map collection factory

Map Collection Factory Java Challenge

In Java 9 we can use Collection Factory with List, Set, or Map. This makes code more concise and easier to read because we donโ€™t need to add element per element in the Map.

Therefore, itโ€™s time to try this fun Java Challenge! Are you ready for the challenge? Check this out:

It's time to improve your Java skills with this Map Collection Factory Challenge - Quiz 40707

Map Collection Factory Challenge

What will happen when running the following code?

map collection factory

Thatโ€™s it challenger, keep breaking your Java limits and solving the Java Challenges!

Written by
Rafael del Nero
Join the discussion

4 comments
  • The is an Error in the Answer! The right answer is:
    java.lang.UnsupportedOperationException will be thrown

    Here comes the error line taken from the program execution log:
    “Exception in thread “main” java.lang.UnsupportedOperationException”

  • I made the Java challenge code and the answer was: Exception in thread “main” java.lang.IllegalArgumentException: duplicate key: no.
    The error was in line 5

Senior Java Interview Questions from Global Companies

Includes detailed answers and practical explanations from real interviews.

Delivered to your email within minutes.