public class ArrayStack {
private int maxStack;
private int[] stack;
private int top = -1;
public ArrayStack(int maxStack) {
this.maxStack = maxStack;
stack = new int[maxStack];
}
public boolean isFull() {
return this.top == this.maxStack - 1;
}
public boolean isEmpty() {
return this.top == -1;
}
public void push(int val) {
if (isFull()) {
throw new RuntimeException("此栈已满。");
}
top++;
stack[top] = val;
}
public int pop() {
if (isEmpty()) {
throw new RuntimeException("空栈,没有数据。");
}
int value = stack[top];
top--;
return value;
}
public void list() {
if (isEmpty()) {
throw new RuntimeException