📄 6.15stacktest.java
字号:
import java.util.*;
class StackTest
{
public static void main(String []args)
{
Stack stack1=new Stack(); //构造一个空堆栈stack1
try{
stack1.push(new Integer(0)); //向栈中逐一压入元素
stack1.push(new Integer(1));
stack1.push(new Integer(2));
stack1.push(new Integer(3));
stack1.push(new Integer(4));
System.out.println((Integer)stack1.pop()); //打印后将元素逐一弹出
System.out.println((Integer)stack1.pop());
System.out.println((Integer)stack1.pop());
System.out.println((Integer)stack1.pop());
System.out.println((Integer)stack1.pop());
}
catch(EmptyStackException e){ }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -