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:
That’s it challenger, keep breaking your Java limits and solving the Java Challenges!
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”
Hi Volodymyr, if you try to run the code you will see that this will be the output:
Exception in thread “main” java.lang.IllegalArgumentException: duplicate key.
You can do your own tests with the code here:
https://github.com/rafadelnero/java-challenges
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
Hey Daniel, exactly. That is the right answer to this Java challenge. Keep it up improving your skills!