How can you find the length and capacity of a string buffer ?

How can you find the length and capacity of a string buffer ?

public int capacity()
Returns the current capacity. The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur.
Returns:
the current capacity.
public int length()
Returns the length (character count).
Specified by:
length in interface CharSequence
Returns:
the length of the sequence of characters currently represented by this object.

By:Sumit Tripathi
Date:2022-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher