This is really a question about a minor detail, but I\'m under the impression to get something wrong here. If you add duplicate keys using Collectors.toMap-method it throws
This is reported as a bug, see JDK-8040892, and it is fixed in Java 9. Reading the commit fixing this, the new exception message will be
String.format("Duplicate key %s (attempted merging values %s and %s)", k, u, v)
where k is the duplicate key and u and v are the two conflicting values mapped to the same key.