package com.data.struct;

public class ArrayStack {
private int[] data;
private int top;

public ArrayStack(int size){
data=new int[size];
top=-1;
}

public void push(int d)throws Exception{
top=top+1;
if(top>=data.length){
throw new Exception("exceed");
}
data[top]=d;
}

public int pop()throws Exception{
if(top==-1){
throw new Exception("no data");
}
top=top-1;
return data[top+1];
}

public static void main(String[] args)throws Exception {
ArrayStack stack=new ArrayStack(10);
stack.push(1);
stack.push(10);
System.out.println(stack.pop());
System.out.println(stack.pop());

}

}