Java streams, create new object based on two different objects
<p>What is the best way to create a new object based on two different objects.</p>

<p>I would like to use java streams.</p>

<p>My two start objects</p>

<pre><code>public class EventA{
    Long id;
    String name;
    ...
    Long locationID;
}

public class EventB{
    Long id
    String Name;
    ...
    Long locationID;
}
</code></pre>

<p>And my result class</p>

<pre><code>public class Result{
    Long locationID;
    String eventAName;
    String eventBName;

    public Result(...){...}
}
</code></pre>

<p>I have two object arrays like</p>

<pre><code>List&lt;EventA&gt; eventAList;
List&lt;EventB&gt; eventBList;
</code></pre>

<p>I like to get an array of <em>Result</em> objects. Every <em>EventA</em> name should be copied to the resultList. If an <em>EventB</em> at the same location exists I would like to save the name in <em>eventBName</em>.</p>

<p>All I have done so far is</p>

<pre><code>List&lt;Result&gt; resultList = eventAList.stream().map(e -&gt; new Result(e.locationID, e.name, null)).collect(Collectors.toList());
</code></pre>

<p>I don't know how to pass the value from <em>EventB</em> to the constructor</p>