1.5 栈

package utillity.stack;

public class MyStack {
	private long[] stackArray;
	private int maxSize;
	private int top;
	
	public MyStack(int s){
		 maxSize = s;
		 stackArray = new long[maxSize];
		 top = -1; 
	 }
	public void push(long x){
		stackArray[++top] = x;
	}
	public long pop(){
		return stackArray[top--];
	}
	public boolean isEmpty(){
		return (top == -1);
	}
	public boolean isFull(){
		return (top == (maxSize-1));
	}
	public void display(){
		while(!this.isEmpty()){
			System.out.print(this.pop()+" ");
		}
	}
}

 

你可能感兴趣的:(栈)