
public class Stack <T>{

	private Object []array;
	private int index=-1;

	public Stack(int size) {
		array = new Object[size];

	}
	public boolean isEmpty(){
		return index==-1;
	}
	public boolean push(T data){
		if(index==array.length-1)
			return false;
		array[++index]=data;
		return true;
	}
	public boolean pop(){
		if(isEmpty())
			return false;
		--index;
		return true;
	}

	public Object top(){
		if(isEmpty())
			return null;
		return array[index];
	}
	public void print(){
		int counter=0;

		while( counter <= index){
			System.out.println(array[counter]);
			++counter;

		}
	}
}
