title: Stack using the Java 8 collection streaming API
body: <p>I have a method which generates an object each time I execute it, and I need to reverse the order with which I am getting them. So I thought the natural way to do it would be a Stack, since it is LIFO.</p>
  
  <p>However, the Java <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Stack.html">Stack</a> does not seem to play well with the new Java 8 streaming API.</p>
  
  <p>If I do this: </p>
  
  <pre><code>   Stack&lt;String&gt; stack = new Stack&lt;String&gt;();
     stack.push("A");
     stack.push("B");
     stack.push("C");
  
     List&lt;String&gt; list = stack.stream().collect(Collectors.toList());
     System.out.println("Collected: " + list);
  </code></pre>
  
  <p>The output I get is: </p>
  
  <pre><code>Collected: [A, B, C]
  </code></pre>
  
  <p>Why isn't it outputing them in the expected LIFO order to the stream?
  Is this the right way to flush out all the items from the stack to a list in the right (LIFO) order? </p>