📄 stackapp.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 + -