title: Why does Collectors.toMap report value instead of key on Duplicate Key error?
body: <p>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 <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html#toMap-java.util.function.Function-java.util.function.Function-" rel="noreferrer">Collectors.toMap-method</a> it throws an Exception with message "duplicate key ". Why is the value reported and not the key? Or even both? This is really misleading, isn't it?</p>
  
  <p>Here's a little test to demonstrate the behaviour:</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.List;
  import java.util.Map;
  import java.util.stream.Collectors;
  
  public class TestToMap {
  
      public static void main(String[] args) {
  
          List&lt;Something&gt; list = Arrays.asList(
              new Something("key1", "value1"),
              new Something("key2", "value2"),
              new Something("key3", "value3a"),
              new Something("key3", "value3b"));
  
          Map&lt;String, String&gt; map = list.stream().collect(Collectors.toMap(o -&gt; o.key, o -&gt; o.value));
          System.out.println(map);
      }
  
      private static class Something {
          final String key, value;
  
          Something(final String key, final String value){
              this.key = key;
              this.value = value;
          }
      }
  }
  </code></pre>