顺序栈 interface StackInterface{ public boolean isempty(); public boolean isfull(); public boolean push(Object k); public Object pop(); public Object get(); } class Stack1 implements StackInterface{ private Object table[]; private final int empty=-1; private int top=empty; public Stack1(int n) { table=new Object[n]; top=empty; } public Stack1() { this(10); } public boolean isempty() { return top==empty; } public boolean isfull() { return top==table.length-1; } public boolean push(Object k) { if(!isfull()) { top++; table[top]=k; return true; } else { System.out.println("栈已满,不能添加"); return false; } } public Object pop() { Object k=null; if(!isempty()) { k=table[top]; table[top]=null; top--; } return k; } public Object get() { if(!isempty()) { return table[top]; } else { return null; } } }