Collectors.toMap with same keys(print same key)
<p>I have this code to get map:</p>

<pre><code>List&lt;MyObject&gt; myList = myMethod.getList();
myList.stream().collect(
    Collectors.toMap(
        MyObject::getKey, 
        MyObject::getValue,
        (e1, e2) -&gt; {
            System.out.println("Duplicate keys !!!");
            return e1;
        }, 
        LinkedHashMap::new
    )
);
</code></pre>

<p>how i can print message "Duplicate keys" with duplicate key?</p>