| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/CSapprenticeWT/OnJava8-Examples/master/collections/StackTest.java | [Back] [Original] |
// collections/StackTest.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import java.util.*;
public class StackTest {
public static void main(String[] args) {
Deque stack = new ArrayDeque();
for(String s : "My dog has fleas".split(" "))
stack.push(s);
while(!stack.isEmpty())
System.out.print(stack.pop() + " ");
}
}
/* Output:
fleas has dog My
*/
| Web Proxy Viewer | New URL | Original Page |