Java Basic

Methods of string builder class

views

19:28
Now let us here discuss some methods which StringBuilder class has that String Class doesn’t. 1) Void setLength(int newLength):- This method helps set the length of the new character sequence. If the newLength is less than the Length() then the last characters of the character sequence get truncated and if it is greater than Length() , then the null characters get added to the character sequence. 2) Void ensureCapacity(int minCapacity):- This method makes it sure that the capacity of the String class is atleast what is specified in the method.