Tuesday, November 17, 2009

StringBuilder class

StringBuilder is generally used as a peferrable replacement for the StringBuffer class. StringBuilder is used to construct a String from other datatypes. The principal operations are append() and insert() methods, which are overloaded to accept anytype of methods. Each method effectively converts a given datum to a string and then appends or inserts the characters of that string to the string builder. The final string is obtained by calling the toString() method.

StringBuilder has 4 types of constructors:
1. StringBuilder()
2. StringBuilder(CharSequence seq) - initialized with seq sequence
3. StringBuilder(int capacity) - constructs a string builder with an initial capacity
4. StringBuilder(String str) - initialized with String str

StringBuilder can perform operations such as reversing, replacing and finding the length of string.


JAVA API
tutorials

No comments:

Post a Comment