title: Java 8 streams - each step in the chain evaluated for entire input or do items get passed through?
body: <p>Say if I have this trivial program</p>
  
  <pre><code>    List&lt;String&gt; input = Arrays.asList("1", "2", "3");
      List&lt;String&gt; result = input.stream()
              .map(x -&gt; x + " " + x)
              .filter(y -&gt; !y.startsWith("1"))
              .collect(Collectors.toList());
  </code></pre>
  
  <p>Behind the scenes does it work like a) or b)</p>
  
  <p>A</p>
  
  <pre><code>map
    "1" + " " + "1"
    "2" + " " + "2"
    "3" + " " + "3"
  filter
    "1 1" does not begin with "1"? = false
    "2 2" does not begin with "1"? = true
    "3 3" does not begin with "1"? = true
  collect
    add "2 2" to list
    add "3 3" to list
  result = List("2 2", "3 3")
  </code></pre>
  
  <p>B</p>
  
  <pre><code>map
    "1" + " " + "1"
  filter
    "1 1" does not begin with "1"? = false
  map
    "2" + " " + "2"
  filter
    "2 2" does not begin with "1"? = true
  collect
    add "2 2" to list
  map
    "3" + " " + "3"
  filter
    "3 3" does not begin with "1"? = true
  collect
    add "3 3" to list
  result = List("2 2", "3 3")
  </code></pre>