title: How to use collect call in Java 8?
body: <p>Lets say we have this boring piece of code that we all had to use:</p>
  
  <pre><code>ArrayList&lt;Long&gt; ids = new ArrayList&lt;Long&gt;();
  for (MyObj obj : myList){
      ids.add(obj.getId());
  }
  </code></pre>
  
  <p>After switching to Java 8, my IDE is telling me that I can replace this code with <code>collect call</code>, and it auto-generates:</p>
  
  <pre><code>ArrayList&lt;Long&gt; ids = myList.stream().map(MyObj::getId).collect(Collectors.toList());
  </code></pre>
  
  <p>However its giving me this error:</p>
  
  <blockquote>
    <p>collect(java.util.stream.Collector) in Steam cannot be applied to: (java.util.stream.Collector, capture, java.util.List>)</p>
  </blockquote>
  
  <p>I tried casting the parameter but its giving me undefined <code>A</code> and <code>R</code>, and the IDE isn't giving any more suggestions.</p>
  
  <p>I'm curious as how can you use <code>collect call</code> in this scenario, and I couldn't find any information that could guide me properly. Can anyone shed a light?</p>