public class Stack {
	
	private static final int DEFAULT_SIZE = 10;
	
	private int store[];
	private int top;
	
	public Stack() {
		
		store = new int[DEFAULT_SIZE];
		
	}
	public boolean empty() {
		
		return top == 0;
		
	}
	
	public void push(int value) {
		
		if (top == store.length)
			grow();
		
		store[top++] = value;
		
	}
	private void grow() {
		
		int oldstore[] = store;
		store = new int[2 * store.length];
		
		for (int i = 0; i < oldstore.length; i++)
			store[i] = oldstore[i];
		
	}
	public int pop() {
		
		if (empty())
			throw new RuntimeException("Trying to pop from empty stack");
		
		return store[--top];
		
	}
}

Comentários