How does `Collectors.toMap` handle duplicate keys and how can you control it?

Topic: java, Modern Java Features (Java 8-21). Level: Intermediate.

The full answer to this question is available to Interview Reader members. See what is free and what Premium adds.