title: Getting the stream object in Collectors toMap method using Method References in Java 8
body: <p>I am trying to iterate a list using <code>stream()</code> and putting in a map, where the key is the steam element itself, and the value is an AtomicBoolean, true. </p>
  
  <pre><code>List&lt;String&gt; streamDetails = Arrays.asList("One","Two");
  toReplay = streamDetails.stream().collect(Collectors.toMap(x -&gt; x.toString(), new AtomicBoolean(true)));
  </code></pre>
  
  <p>I get the below errors at compile time.</p>
  
  <pre><code>Type mismatch: cannot convert from String to K
  The method toMap(Function&lt;? super T,? extends K&gt;, Function&lt;? super T,? extends U&gt;) in the type Collectors is not applicable for the arguments ((&lt;no type&gt; x) -&gt; {}, 
       AtomicBoolean)
  </code></pre>
  
  <p>What could I be doing wrong, what shall I replace my <code>x -&gt; x.toString()</code> with?</p>