import java.util.ArrayList;


public class MyQueue<Type> {
	private ArrayList<Type> list;
	
	public MyQueue() {
		list = new ArrayList<Type>();
	}
	
	public void push(Type element) {
		list.add(0, element);
	}
	
	public Type pop() {
		return list.remove(list.size() - 1);
	}
	
	public Type peek() {
		return list.get(list.size() - 1);
	}
	
	public boolean empty() {
		return list.isEmpty();
	}
	
	public static void main(String[] args) {
		MyQueue<Integer> q = new MyQueue<Integer>();
		
		q.push(5);
		q.push(7);
		q.push(9);
		q.push(3);
		
		System.out.println("Peeking at first element: " + q.peek());
		
		while (!q.empty()) {
			System.out.println(q.pop());
		}
	}
}

