public int remove(final int key){
  final int valPos=pointer - key;
  final int result=stack[valPos];
  final int[] newStack=new int[stack.length];
  System.arraycopy(stack,0,newStack,0,valPos);
  System.arraycopy(stack,valPos + 1,newStack,valPos,(stack.length - valPos) - 1);
  stack=newStack;
  pointer--;
  return result;
}

public int remove ( final int key ) { final int valPos = pointer - key ; final int result = stack [ valPos ] ; final int [ ] newStack = new int [ stack . length ] ; System . arraycopy ( stack , 0 , newStack , 0 , valPos ) ; System . arraycopy ( stack , valPos + 1 , newStack , valPos , ( stack . length - valPos ) - 1 ) ; stack = newStack ; pointer -- ; return result ; }
removes an item from the stack
