IntegerStack { public synchronized void clear() { if (data.length > CLEAR_SIZE) { data = new Integer[CHUNK_SIZE]; } index = -1; }  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 clear() { stk.push(1); stk.push(2); stk.push(3); stk.clear(); assertEquals(0, stk.size()); }