title: Using streams, how can I map the values in a HashMap?
body: <p>Given a <code>Map&lt;String, Person&gt;</code> where Person has a <code>String getName()</code> (etc) method on it, how can I turn the <code>Map&lt;String, Person&gt;</code> into a <code>Map&lt;String, String&gt;</code> where the <code>String</code> is obtained from calling <code>Person::getName()</code>?</p>
  
  <p>Pre-Java 8 I'd use</p>
  
  <pre><code>Map&lt;String, String&gt; byNameMap = new HashMap&lt;&gt;();
  
  for (Map.Entry&lt;String, Person&gt; person : people.entrySet()) {
      byNameMap.put(person.getKey(), person.getValue().getName());
  }
  </code></pre>
  
  <p>but I'd like to do it using streams and lambdas.</p>
  
  <p>I can't see how to do this in a functional style: Map/HashMap don't implement <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html" rel="noreferrer"><code>Stream</code></a>.</p>
  
  <p><code>people.entrySet()</code> returns a <code>Set&lt;Entry&lt;String, Person&gt;&gt;</code> which I can stream over, but how can I add a new <code>Entry&lt;String, String&gt;</code> to the destination map?</p>