Java ensureCapacity() Vs setLength() Vs trimToSize()

ensureCapacity() vs setLength() vs trimToSize() StringBuffer

Before going into the table of ensureCapacity() vs setLength() vs trimToSize(), it is advised to refer the programs at: ensureCapacity() StringBuffer Example setLength() StringBuffer Example trimToSize() StringBuffer Example Following terminology is to be remembered: Length: It is the number of characters present in the buffer (which generally be same or…