title: How can I get a List from some class properties with Java 8 Stream?
body: <p>I have a <code>List&lt;Person&gt;</code>. I need to get a <code>List</code> from a property of <code>Person</code>.</p>
  
  <p>For example, I have a <code>Person</code> class:</p>
  
  <pre><code>class Person
  {
      private String name;
      private String birthDate;
      public String getName() {
          return name;
      }
      public String getBirthDate() {
          return birthDate; 
      }
      Person(String name) {
          this.name = name;
      }
  }
  
  List&lt;Person&gt; personList = new ArrayList&lt;&gt;();
  personList.add(new Person("David"));
  personList.add(new Person("Joe"));
  personList.add(new Person("Michel"));
  personList.add(new Person("Barak"));
  </code></pre>
  
  <p>I want to get a list of names with the <code>Stream</code> API, like this:</p>
  
  <pre><code>List&lt;String&gt; names = personList.stream().somecode().collect(Collectors.toList());
  names.stream().forEach(System.out::println);
  
  #David
  #Joe
  #Michel
  #Barak
  </code></pre>
  
  <p>This code doesn't work:</p>
  
  <pre><code>public class Main 
  {
      public static void main(String[] args) 
      {
          List&lt;Person&gt; personList = new ArrayList&lt;&gt;();
          Person person = new Person("Иван");
          person.getFriends().addAll(Arrays.asList("Друг 1", "Друг 2", "Друг 3"));
          personList.add(person);
          person = new Person("Федор");
          person.getFriends().addAll(Arrays.asList("Друг 4", "Друг 5", "Друг 6"));
          personList.add(person);
          person = new Person("Алексей");
          person.getFriends().addAll(Arrays.asList("Друг 7", "Друг 8", "Друг 9"));
          personList.add(person);
          person = new Person("Константин");
          person.getFriends().addAll(Arrays.asList("Друг 10", "Друг 11", "Друг 12"));
  
          List&lt;String&gt; friens = personList.stream().map(e-&gt;e.getFriends()).collect(Collectors.toList());
  
          friends.stream().forEach(System.out::println);
          //Друг 1
          //Друг 2
          //Друг 3
          //Друг 4
          //...
  
      }
  }
  
  class Person
  {
      String name;
      List&lt;String&gt; friends;
  
      Person(String name) {
          this.name = name;
      }
      public String getName() {
          return name;
      }
  
      public List&lt;String&gt; getFriends() {
          return friends;
      }
  }
  </code></pre>
  
  <p><br>
  How can I get a <code>List</code> of a property with <code>Stream</code> API? </p>