Share via


StringBuffer.ensureCapacity

Class Overview | Class Members | This Package | All Packages

Syntax

public synchronized void ensureCapacity( int minimumCapacity )

Parameters
  • minimumCapacity
    the minimum desired capacity.
Description

Ensures that the capacity of the buffer is at least equal to the specified minimum. If the current capacity of this string buffer is less than the argument, then a new internal buffer is allocated with greater capacity. The new capacity is the larger of:

  • The minimumCapacity argument.
  • Twice the old capacity, plus 2.

If the minimumCapacity argument is nonpositive, this method takes no action and simply returns.