// 弹出数据 public T pop(){ T t = stack[size - 1]; size--; return t; } //Returns the 1-based position where an object is on this stack publicintsearch(T t){ for(int i =size-1; i>=0; i--){ if(stack[i].equals(t)){ return size-i; } } return -1; } //获取容量 publicintsize(){ return size; } }