title: Java 8 get all employee having address start with P
body: <p>I have employee and address class as below</p>
  
  <pre><code>class Employee {
      private String name;
      private int age;
      private List&lt;Address&gt; addresses;
      //getter and setter
  }
  
  class Address {
      private String city;
      private String state;
      private String country;
      //getter and setter
  }
  </code></pre>
  
  <p>Using java 8 filter I want to print all employees who are having city starting with P</p>
  
  <p>What to add to below code to get emp of that filtered address</p>
  
  <pre><code>employees.stream()
      .map(Employee::getAddresses)
      .flatMap(Collection::stream)
      .filter(children -&gt; children.getCity().startsWith("p"))
      .collect(Collectors.toList())
      .forEach(System.out::println);
  </code></pre>
  
  <p>Thanks in advance.</p>