title: Is there a 'mechanism' to assign stream operation values to a local variable in Java 8?
body: <p>I assume the answer is no but wanted to check there isn't an elegant work around.  I want to add an unknown number of subquery operations to a JPA criteriabQuery in a java 8 app and was hoping to do something like this</p>
  
  <pre><code>Expression where = null;
  
  where = criteriaBuilder.in(from.get(fieldsList.get(0)... )
  
  fieldsList.stream().skip(1)
  .forEachOrdered(i -&gt; where = criteriaBuilder
  .and(criteriaBuilder.in(from.get(i)).value(getSubquery(edmEntityType,
  entityClass, criteriaBuilder, criteriaQuery, from, i)), where));
  </code></pre>
  
  <p>as I'm referencing a number of locval variables this is a no no and I have used a for loop instead </p>
  
  <pre><code>for (int i = 1; i &lt; fieldsList.size(); i++){
      where ... 
  }
  </code></pre>
  
  <p>I just wondored if there was a more elegant solution ?</p>