OnJava8-Examples/collections/StackTest.java
2015-12-15 11:47:04 -08:00

19 lines
514 B
Java

// collections/StackTest.java
// (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
import onjava.*;
public class StackTest {
public static void main(String[] args) {
Stack<String> stack = new Stack<>();
for(String s : "My dog has fleas".split(" "))
stack.push(s);
while(!stack.empty())
System.out.print(stack.pop() + " ");
}
}
/* Output:
fleas has dog My
*/