Stack using the Java 8 collection streaming API
问题 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. However, the Java Stack does not seem to play well with the new Java 8 streaming API. If I do this: Stack<String> stack = new Stack<String>(); stack.push("A"); stack.push("B"); stack.push("C"); List<String> list = stack.stream().collect(Collectors.toList()); System.out.println("Collected: " +