RosettaCodeData/Task/Stack/Java/stack-1.java

22 lines
657 B
Java
Raw Normal View History

2014-01-17 05:32:22 +00:00
import java.util.Stack;
public class StackTest {
public static void main( final String[] args ) {
final Stack<String> stack = new Stack<String>();
System.out.println( "New stack empty? " + stack.empty() );
stack.push( "There can be only one" );
System.out.println( "Pushed stack empty? " + stack.empty() );
System.out.println( "Popped single entry: " + stack.pop() );
stack.push( "First" );
stack.push( "Second" );
System.out.println( "Popped entry should be second: " + stack.pop() );
// Popping an empty stack will throw...
stack.pop();
stack.pop();
2013-04-11 01:07:29 -07:00
}
}