import java.util.Stack;
public class zhan {
public static void main(String args[]) {
Stack<String>stack=new Stack();
stack.add("a");
stack.add("b");
stack.add("c");
while(stack.size()>0) {
System.out.println(stack.pop()); //取出栈里的数据
}
}
}
结果
c
b
a