seqstackapp.java

来自「基本数据结构」· Java 代码 · 共 36 行

JAVA
36
字号
package seqStack;

import seqStack.SeqStack.FullStackException;

public class SeqStackApp 
{
	public static void main(String[] args) 
	{
		System.out.println("SeqStack Demo");
		System.out.println("-------------");
		seqStackApp(new SeqStack(4));
	}
	static void seqStackApp(Stack s)
	{
		System.out.println("Pushing \"Hello\"");
		s.push("Hello");
		System.out.println("Pushing \" World\"");
		s.push("World");
		System.out.println("Pushing SeqStackApp Object");
		s.push(new SeqStackApp());
		System.out.println("Pushing Character object");
		s.push("A");
		System.out.println();
		try
		{
			System.out.println("Pushing \"One last item\"");
			s.push("One last item");
		}catch(FullStackException e){System.out.println ("One push too many");}
		System.out.println(s.getTop());
		while(s.notEmpty()) System.out.println(s.pop());
		try{s.pop();}catch(java.util.EmptyStackException e){System.out.println("Stack is empty!"); };
		System.out.println();
		
	}
}

⌨️ 快捷键说明

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