code: public final void setElementStackCapacity(int newCapacity) throws IllegalArgumentException, OutOfMemoryError {
  
          // Check argument
          if (newCapacity < _elementStack.length) {
              throw new IllegalArgumentException("newCapacity < getElementStackSize()");
          }
  
          int currentCapacity = _elementStack.length;
  
          // Short-circuit if possible
          if (currentCapacity == newCapacity) {
              return;
          }
  
          String[] newStack = new String[newCapacity];
          System.arraycopy(_elementStack, 0, newStack, 0, _elementStackSize);
          _elementStack = newStack;
  
          // State has changed, check
          checkInvariants();
      }
docs: Sets the capacity for the stack of open elements. The new capacity must
  at least allow the stack to contain the current open elements.
  
  @param newCapacity the new capacity, &gt;= {@link #getElementStackSize()}.
  @throws IllegalArgumentException if <code>newCapacity &lt; {@link #getElementStackSize()}</code>.
  @throws OutOfMemoryError         if a new array cannot be allocated; this object will still be usable,
  but the capacity will remain unchanged.