java-自定义栈
class StackClass
{
int[] arr=new int[10];
private int index;
public StackClass()
{
this.index=-1;
}
public void push(int number)
{
if(this.index<this.arr.length)
this.arr[++index]=number;
else
System.out.println("Stack is full...");
}
public int pop()
{
if(this.index>=0)
return this.arr[this.index--];
else
{
System.out.println("Stack is empty...");
return 0;
}
}
}