IntegerStack { public synchronized Integer peek() { if (index >= 0) { return data[index]; } throw new RuntimeException("Stack is empty"); }  synchronized Integer push(Integer x); synchronized Integer pop(); synchronized Integer peek(); synchronized void clear(); int size(); static final int CHUNK_SIZE; static final int CLEAR_SIZE; }
@Test public void peek() { stk.push(1); assertEquals(1, stk.peek().intValue()); stk.push(null); assertNull(stk.peek()); stk.pop(); assertEquals(1, stk.peek().intValue()); }