?? 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 + -