title: Create a map from two different lists based on common conditions using Java 8 Streams
body: <p>I have two list instances like this:</p>
  
  <pre><code>List&lt;NameAndAge&gt; nameAndAgeList = new ArrayList&lt;&gt;();
  nameAndAgeList.add(new NameAndAge("John", "28"));
  nameAndAgeList.add(new NameAndAge("Paul", "30"));
  nameAndAgeList.add(new NameAndAge("Adam", "31"));
  
  List&lt;NameAndSalary&gt; nameAndSalaryList = new ArrayList&lt;&gt;();
  nameAndSalaryList.add(new NameAndSalary("John", 1000));
  nameAndSalaryList.add(new NameAndSalary("Paul", 1100));
  nameAndSalaryList.add(new NameAndSalary("Adam", 1200));
  </code></pre>
  
  <p>where <code>NameAndAge</code> is</p>
  
  <pre><code>class NameAndAge {
      public String name;
      public String age;
  
      public NameAndAge(String name, String age) {
          this.name = name;
          this.age = age;
      }
  
      @Override
      public String toString() {
          return name + ": " + age;
      }
  }
  </code></pre>
  
  <p>and <code>NameAndSalary</code> is</p>
  
  <pre><code>private class NameAndSalary {
      private String name;
      private double salary;
  
      public NameAndSalary(String name, double salary) {
          this.name = name;
          this.salary = salary;
      }
  
      @Override
      public String toString() {
          return name + ": " + salary;
      }
  }
  </code></pre>
  
  <p>Now, I want to create a map with key as <code>NameAndAge</code> object from the first list and value as <code>NameAndSalary</code> from the second list where the name is equal in both the objects.</p>
  
  <p>So, when I print the map, it should look like this:</p>
  
  <pre><code>{John: 28=John: 1000.0}
  {Paul: 30=Paul: 1100.0}
  {Adam: 31=Adam: 1200.0}
  </code></pre>
  
  <p>I have tried doing this, but the end return type is 'void' so I'm stuck clueless as I am new to Streams.</p>
  
  <pre><code>nameAndAgeList
      .forEach(n -&gt;
          nameAndSalaryList
              .stream()
              .filter(ns -&gt; ns.name.equals(n.name))
              .collect(Collectors.toList()));
  </code></pre>
  
  <p>Can someone please advise how can this be achieved with Java Streams API?</p>