title: How to convert a List of strings into a Map with Streams
body: <p>I have to convert a list <code>List&lt;String&gt;</code> into a map <code>Map&lt;String, Float&gt;</code>.</p>
  <p>The <em>keys</em> of the <em>map</em> must be strings from the <em>list</em>, and every <strong>value</strong> must be <code>0</code> (zero) for all <em>keys</em>.</p>
  <p>How can I convert this?</p>
  <p>I've tried:</p>
  <pre class="lang-java prettyprint-override"><code>List&lt;String&gt; list = List.of(&quot;banana&quot;, &quot;apple&quot;, &quot;tree&quot;, &quot;car&quot;);
  
  Map&lt;String, Float&gt; map = list.stream()
      .distinct()
      .collect(Collectors.toMap(String::toString, 0f));
  </code></pre>