stack.java

来自「由于想一次上传成功 所以将二个教程打包成了一个 这些例子几乎包含了所有java的」· Java 代码 · 共 29 行

JAVA
29
字号
import java.util.*;
 
class stack 
{
    public static void main(String args[]) 
    {
        Stack stack1 = new Stack();

        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));
            stack1.push(new Integer(5));
            stack1.push(new Integer(6));

            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());
            System.out.println((Integer) stack1.pop());
            System.out.println((Integer) stack1.pop());
        } 
        catch (EmptyStackException e) {}
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?