(String[] args)
| 6 | |
| 7 | public class StackTest { |
| 8 | public static void main(String[] args) { |
| 9 | Deque<String> stack = new ArrayDeque<>(); |
| 10 | for(String s : "My dog has fleas".split(" ")) |
| 11 | stack.push(s); |
| 12 | while(!stack.isEmpty()) |
| 13 | System.out.print(stack.pop() + " "); |
| 14 | } |
| 15 | } |
| 16 | /* Output: |
| 17 | fleas has dog My |