stack.java
来自「数据结构 包括数组(Array包) 和二叉树(Tree) 链表(Linelis」· Java 代码 · 共 35 行
JAVA
35 行
package Array;
public class Stack {
int stacktop;
int stackMax;
int[] stack;
public Stack(int stackMax){
stacktop=-1;
stack=new int[stackMax];
}
public void push(int key){
stacktop++;
stack[stacktop]=key;
}
public int pop(){
int result=stack[stacktop];
stacktop--;
return result;
}
public int peek(){
return stack[stacktop];
}
public boolean stackIsEmpty(){
if(stacktop==-1)
return true;
else
return false;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?