title: How to combine two streams?
body: <p>I'm trying to learn/understand streams in java and have this piece of code:</p>
  
  <pre><code>List &lt;Tag&gt; tags = (classA.getTags() != null ? classA.getTags() : new ArrayList&lt;&gt;());
  List &lt;Integer&gt; tagsIds = new ArrayList&lt;&gt;(Arrays.asList(1,2,3,4));
  List&lt;Integer&gt; ids = tags.stream().map(Tag::getId).collect(Collectors.toList());
  tagIds.stream()
        .filter(tagId -&gt; !ids.contains(tagId))
        .forEach(tagId -&gt; {
           Tag tag = new Tag();
           tag.setId(tagId);
           tags.add(tag);
         });
  </code></pre>
  
  <p>Please, give me a tip how I can combine two streams into one?</p>
  
  <p>------- Added 23.08.2018 --------<br>
  If we get rid of <code>ids</code> variable it will improve a bit performance and code below perform as we work with <code>Set &lt;Integer&gt; tagsIds</code>, so no duplicates (e.g. if <code>tagIds</code> contains values (5,6,7,8,5,6,7) it will work only with (5,6,7,8)). Below the modified code:</p>
  
  <pre><code>List &lt;Tag&gt; tags = (classA.getTags() != null ? classA.getTags() : new ArrayList&lt;&gt;());
  List &lt;Integer&gt; tagIds = new ArrayList&lt;&gt;(Arrays.asList(5,6,7,8,5,6,7));
  tagIds.stream()
        .filter(tagId -&gt; !tags.stream().map(Tag::getId).collect(Collectors.toList()).contains(tagId))
        .forEach(tagId -&gt; {
              Tag tag = new Tag();
              tag.setId(tagId);
              tags.add(tag);
         });
  </code></pre>
  
  <p>This modification has disadvantages like the complexity of reading and debugging code</p>