package mystack;publicclassArrayStack{privateint top;//当前栈顶元素的下标privateint[] array;publicArrayStack(){
array =newint[10];
top =-1;}publicbooleanisEmpty(){return top ==-1;}publicbooleanisFull(){return top == array.length -1;}publicvoidpush(int data){if(isFull()) System.out.println("Stack Overflow!!");else{
array[++top]= data;}}publicintpop(){if(isEmpty()){
System.out.println("Stack is empty!!");return0;}else{return array[top--];}}publicvoiddeleteStack(){
top =-1;}}