-->
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, August 20, 2017

String Buffer

java.lang.StringBuffer
StringBuffer is another class present in Java which allows us to manipulate strings.This class is just like the String class except the fact that the strings created by this class are mutable.It is also thread-safe which means multiple threads cannot operate on the string. 
The StringBuffer class implements:
i)Serializable interface
ii)Appendable interface
iii)CharSequence interface


Constructors of StringBuffer class


Constructors

Description

StringBuffer() Constructs a string buffer with no characters in it and an initial capacity of 16 characters.
StringBuffer(CharSequence seq) Constructs a string buffer that contains the same characters as the specified CharSequence.
StringBuffer(int capacity) Constructs a string buffer with no characters in it and the specified initial capacity.
StringBuffer(String str) Constructs a string buffer initialized to the contents of the specified string.


Methods of StringBuffer class


Modifiers and type

Methods

Description

public int capacity() is used to return the current capacity.
public void ensureCapacity(int minimumCapacity) is used to ensure the capacity at least equal to the given minimum.
public char charAt(int index) is used to return the character at the specified position.
public synchronized StringBuffer delete(int startIndex, int endIndex) is used to delete the string from specified startIndex and endIndex.

No comments:

Post a Comment