title: Collecting lists from an object list using Java 8 Stream API
body: <p>I have a class like this</p>
  
  <pre><code>public class Example {
      private List&lt;Integer&gt; ids;
  
      public getIds() {
          return this.ids; 
      }
  }
  </code></pre>
  
  <p>If I have a list of objects of this class like this</p>
  
  <pre><code>List&lt;Example&gt; examples;
  </code></pre>
  
  <p>How would I be able to map the id lists of all examples into one list?
  I tried like this:</p>
  
  <pre><code>List&lt;Integer&gt; concat = examples.stream().map(Example::getIds).collect(Collectors.toList());
  </code></pre>
  
  <p>but getting an error with <code>Collectors.toList()</code></p>
  
  <p>What would be the correct way to achive this with Java 8 stream api?</p>