title: Java Stream .map ternary operator
body: <p>I have a TXT.File with Lines which are representing some Objects</p>
  <blockquote>
  <p>R-Line (one)</p>
  <p>RN-Line (1...many)</p>
  </blockquote>
  <p>they are connected with id so in order to read the file I made a <code>lines().stream</code></p>
  <pre><code>Stream&lt;Boolean&gt; inLines = in.lines()
           //limit lines due to memory footprint
          .limit(10)
           //filter each line by the given id
          .filter(identN -&gt; ident.matches(&quot;.*\\t[5]\\t.*&quot;))
          /**
           * should return all lines with id 5
           * if line starts with RN put it in rnArray else in rArray so the objects are connected but i need for validation purposes each line seperate??
           */
          .map(y -&gt; (y.startsWith(&quot;RN&quot;) ? synonym1.add(y) : substance.add(y)));
           
  
  System.out.println(&quot;syn1 = &quot; + synonym1.toString() + &quot;substance: = &quot; + substance + &quot; InLines&quot;+ inLines);
  </code></pre>
  <p>Response is empty :</p>
  <pre><code>syn1 = []substance: = [] InLinesjava.util.stream.ReferencePipeline$3@3aa9e816
  </code></pre>
  <p>But it doesn't work. The return of the .map should be another stream so how can I incorporate this logic if I use for each it won't work since I need also the r-Line.</p>