@Test public void push() throws Exception { IntStack stack = new IntStack(4); stack.push(1); assertThat(stack.peek(), is(1)); assertThat(stack.size(), is(1)); stack.push(2); assertThat(stack.peek(), is(2)); assertThat(stack.size(), is(2)); stack.push(4); assertThat(stack.peek(), is(4)); assertThat(stack.size(), is(3)); }
void push(final int x) { if (n == xs.length) xs = Arrays.copyOf(xs, xs.length * 2); xs[n++] = x; }
IntStack { void push(final int x) { if (n == xs.length) xs = Arrays.copyOf(xs, xs.length * 2); xs[n++] = x; } }
IntStack { void push(final int x) { if (n == xs.length) xs = Arrays.copyOf(xs, xs.length * 2); xs[n++] = x; } IntStack(final int n); }
IntStack { void push(final int x) { if (n == xs.length) xs = Arrays.copyOf(xs, xs.length * 2); xs[n++] = x; } IntStack(final int n); int size(); void clear(); }
IntStack { void push(final int x) { if (n == xs.length) xs = Arrays.copyOf(xs, xs.length * 2); xs[n++] = x; } IntStack(final int n); int size(); void clear();  }