title: Merging Map streams using Java 8 Lambda Expression
body: <p>I have two maps <code>m1</code> and <code>m2</code> of type <code>Map&lt;Integer, String&gt;</code>, which has to be merged into a single map
  <code>Map&lt;Integer, List&lt;String&gt;&gt;</code>, where values of same keys in both the maps are collected into a List and put into a new Map.</p>
  <p>Solution based on what I explored:</p>
  <pre class="lang-java prettyprint-override"><code>Map&lt;Integer, List&lt;String&gt;&gt; collated =
          Stream.concat(m1.entrySet().stream(), m2.entrySet().stream()).collect(
                  Collectors.toMap(Entry::getKey,
                          Entry::getValue, (a, b) -&gt; {
                              List&lt;String&gt; merged = new ArrayList&lt;String&gt;(a);
                              merged.addAll(b);
                              return merged;
                          }));
  </code></pre>
  <p>But, this solution expects source <code>List</code> to be <code>Map&lt;Integer, List&lt;String&gt;&gt;</code> as the merge function in toMap expects operands and result to be of the same type.</p>
  <p>I don't want to change the source collection. Please provide your inputs on achieving this using lambda expression.</p>