⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stackapp.java

📁 java 数据结构的一些简单实例和一些线程的应用主要是面向初学者
💻 JAVA
字号:
import java.io.*;
class Stack{
	int size;
	int[] a;
	int top;
	
	public Stack(int value){
		size=value;
		a=new int[size];
		top=-1;
	}
	public void push(int value){
		a[++top]=value;
	}
	public int pop(){
		return  a[top--];
	}
	public int peek(){
		return a[top];
	}
	public boolean isfull(){
		return (top==size-1);
	}
	public boolean isempty(){
		return(top==-1);
	}
	
}

public class StackApp{
	public static void main(String[] args)throws IOException{
		int max=10;
		Stack s=new Stack(max);
		s.push(10);
		s.push(20);
		s.push(30);
		s.push(40);
		
		while(!s.isempty())
		{
			int value=s.pop();
			System.out.println(value);
		}
	}
}


⌨️ 快捷键说明

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