title: How to replace nested loops with Java 8 streams
body: <p>I want to use Java 8 stream for the below implementation. Basically i want to parse one list and form another list of different objects.</p>
  
  <p><strong>Input</strong> - list of Person pojos, 
  <strong>Output</strong> - list of PersonInfo pojos</p>
  
  <pre><code>    List&lt;Person&gt; persons = new ArrayList&lt;Person&gt;();
  
      Person max = new Person();
      max.setName("Max");
      max.setAge(10);
      max.addAddress(new Address("Street1", "City1"));
      max.addAddress(new Address("Street2", "City2"));
  
      Person peter = new Person();
      peter.setName("Peter");
      peter.setAge(20);
      peter.addAddress(new Address("Street1", "City1"));
      peter.addAddress(new Address("Street2", "City2"));
  
      persons.add(max);
      persons.add(peter);
  
      System.out.println("Input: " + persons);
  
      List&lt;PersonInfo&gt; personInfos = new ArrayList&lt;PersonInfo&gt;();
      PersonInfo personInfo = null;
      for (Person person : persons) {
          for (Address addr : person.getCurrAndPrevAddrs()) {
              personInfo = new PersonInfo();
              personInfo.setName(person.getName());
              personInfo.setAge(person.getAge());
              personInfo.setAddrs(addr);              
              personInfos.add(personInfo);
          }
      }
  
      System.out.println("Output: " + personInfos.toString());
  </code></pre>
  
  <p><strong>sample output</strong>:
  <strong>Input</strong>: [Max 10  [Street1    City1, Street2  City2]</p>
  
  <p>, Peter 20  [Street1    City1, Street2  City2]]</p>
  
  <p><strong>Output</strong>: [Max    10  Street1 City1</p>
  
  <p>, Max   10  Street2 City2</p>
  
  <p>, Peter 20  Street1 City1</p>
  
  <p>, Peter 20  Street2 City2]</p>