OnJava8-Examples/containers/StackTest.java
Bruce Eckel bc0026c3e1 Radically reorganized
Plus many new examples in "streams" chapter.
2015-11-11 20:20:04 -08:00

16 lines
333 B
Java

// containers/StackTest.java
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
*/