title: Difference between forEachOrdered() and sequential() methods of Java 8?
body: <p>I am working on java 8 parallel stream and wanting to print the elements in parallel stream is some order (say insertion order, reverse order or sequential order).</p>
  
  <p>For which i tried the following code:</p>
  
  <pre><code>        System.out.println("With forEachOrdered:");
          listOfIntegers
              .parallelStream()
              .forEachOrdered(e -&gt; System.out.print(e + " "));
          System.out.println("");
  
          System.out.println("With Sequential:");
          listOfIntegers.parallelStream()
                      .sequential()
                      .forEach(e -&gt; System.out.print(e + " "));
  </code></pre>
  
  <p>And for both of these, i got the same output as follows:</p>
  
  <pre><code>With forEachOrdered:
  1 2 3 4 5 6 7 8 
  With Sequential:
  1 2 3 4 5 6 7 8 
  </code></pre>
  
  <p>from the api documentation, i can see that:</p>
  
  <blockquote>
    <p>forEachOrdered ->  This is a terminal operation.</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>sequential  -> This is an intermediate operation.</p>
  </blockquote>
  
  <p>So my question is which one is more better to use?
  and in which scenarios, one should be preferred over other?</p>