@@ -1 +1,2063 @@
+import java.util.Arrays;%0A%0Aclass IntStack %7B%0A%0A  private int stack%5B%5D;%0A%0A  private int top;%0A%0A  static int SIZE = 16; %0A%0A  static int MINSIZE = 1 %3C%3C 15; %0A%0A  IntStack() %7B%0A    this(SIZE);%0A  %7D%0A%0A  IntStack(final int size) %7B%0A    stack = new int%5Bsize%5D;%0A    clear();%0A  %7D%0A%0A  final int getTop() %7B%0A    return top;%0A  %7D%0A%0A  final int setTop(final int top) %7B%0A    return this.top = top;%0A  %7D%0A%0A  final void clear() %7B%0A %0A    top = -1;%0A  %7D%0A%0A  final boolean isEmpty() %7B%0A    return top %3C 0;%0A  %7D%0A%0A  final void push(final int i) %7B%0A%0A    if (++top %3E= stack.length) %7B%0A      expand();%0A    %7D%0A    stack%5Btop%5D = i;%0A  %7D%0A%0A  final int pop() %7B%0A    final int r = stack%5Btop--%5D;%0A    shrink();%0A    return r;%0A  %7D%0A%0A  final int get(final int i) %7B%0A    return stack%5Bi%5D;%0A  %7D%0A%0A  final void set(final int i, final int val) %7B%0A    stack%5Bi%5D = val;%0A  %7D%0A%0A  final int size() %7B%0A    return top + 1;%0A  %7D%0A%0A%0A  private final void expand() %7B%0A    final int l = stack.length;%0A    final int%5B%5D newstack = new int%5Bl %3C%3C 1%5D;%0A%0A    System.arraycopy(stack, 0, newstack, 0, l);%0A    stack = newstack;%0A  %7D%0A%0A%0A  private final void shrink() %7B%0A    int l = stack.length;%0A    if (l %3C= MINSIZE %7C%7C top %3C%3C 2 %3E= l)%0A      return;%0A    l = 1 + (top %3C%3C 1); %0A    if (top %3C MINSIZE) %7B%0A      l = MINSIZE;%0A    %7D%0A%0A    final int%5B%5D newstack = new int%5Bl%5D;%0A    System.arraycopy(stack, 0, newstack, 0, top + 1);%0A    stack = newstack;%0A  %7D%0A%0A  int%5B%5D toArray() %7B%0A    final int%5B%5D array = new int%5Bsize()%5D;%0A    if (size() %3E 0) %7B%0A      System.arraycopy(stack, 0, array, 0, size());%0A    %7D%0A    return array;%0A  %7D%0A%0A  public final void reverse() %7B%0A    int l = size();%0A    int h = l %3E%3E 1;%0A    for (int i = 0; i %3C h; i++) %7B%0A      int temp = stack%5Bi%5D;%0A      stack%5Bi%5D = stack%5Bl - i - 1%5D;%0A      stack%5Bl - i - 1%5D = temp;%0A    %7D%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    return Arrays.toString(toArray());%0A  %7D%0A%0Apublic static void main(final String%5B%5D args) %7B%0A    IntStack s=new IntStack();%0As.push(100);%0As.push(200);%0As.push(300);%0As.push(400);%0As.push(500);%0As.push(600);%0As.push(700);%0As.push(800);%0ASystem.out.println(%22The size of stack is: %22);%0ASystem.out.println(s.getTop()+1);%0A%0A%0A  %7D%0A%7D
 %0A

Update GG.java