- Java.lang - Void
- Java.lang - Throwable
- Java.lang - ThreadLocal
- Java.lang - ThreadGroup
- Java.lang - Thread
- Java.lang - System
- Java.lang - StringBuilder
- Java.lang - StringBuffer
- Java.lang - String
- Java.lang - StrictMath
- Java.lang - StackTraceElement
- Java.lang - Short
- Java.lang - SecurityManager
- Java.lang - RuntimePermission
- Java.lang - Runtime
- Java.lang - ProcessBuilder
- Java.lang - Process
- Java.lang - Package
- Java.lang - Object
- Java.lang - Number
- Java.lang - Math
- Java.lang - Long
- Java.lang - Integer
- Java.lang - InheritableThreadLocal
- Java.lang - Float
- Java.lang - Enum
- Java.lang - Double
- Java.lang - Compiler
- Java.lang - ClassLoader
- Java.lang - Class
- Java.lang - Character.UnicodeBlock
- Java.lang - Character.Subset
- Java.lang - Character
- Java.lang - Byte
- Java.lang - Boolean
- Java.lang - Home
Java.lang Package extras
Java.lang Package Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.lang.StringBuilder Class
Introduction
The java.lang.StringBuilder class is mutable sequence of characters. This provides an API compatible with StringBuffer, but with no guarantee of synchronization.
Class Declaration
Following is the declaration for java.lang.StringBuilder class −
pubpc final class StringBuilder extends Object implements Seriapzable, CharSequence
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 |
StringBuilder() This constructs a string builder with no characters in it and an initial capacity of 16 characters. |
2 |
StringBuilder(CharSequence seq) This constructs a string builder that contains the same characters as the specified CharSequence. |
3 |
StringBuilder(int capacity) This constructs a string builder with no characters in it and an initial capacity specified by the capacity argument. |
4 |
StringBuilder(String str) This constructs a string builder initiapzed to the contents of the specified string. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method appends the string representation of the boolean argument to the sequence. |
2 | This method appends the string representation of the char argument to this sequence. |
3 | This method appends the string representation of the char array argument to this sequence. |
4 | This method appends the string representation of a subarray of the char array argument to this sequence. |
5 | This method appends the specified character sequence to this Appendable. |
6 | This method appends a subsequence of the specified CharSequence to this sequence. |
7 | This method appends the string representation of the double argument to this sequence. |
8 | This method appends the string representation of the float argument to this sequence. |
9 | This method appends the string representation of the int argument to this sequence. |
10 | This method appends the string representation of the long argument to this sequence. |
11 | This method appends the string representation of the Object argument. |
12 | This method appends the specified string to this character sequence. |
13 | This method appends the specified StringBuffer to this sequence. |
14 | This method appends the string representation of the codePoint argument to this sequence. |
15 | This method returns the current capacity. |
16 | This method returns the char value in this sequence at the specified index. |
17 | This method returns the character (Unicode code point) at the specified index. |
18 | This method returns the character (Unicode code point) before the specified index. |
19 | This method returns the number of Unicode code points in the specified text range of this sequence. |
20 | This method removes the characters in a substring of this sequence. |
21 | This method removes the char at the specified position in this sequence. |
22 | This method ensures that the capacity is at least equal to the specified minimum. |
23 | Characters are copied from this sequence into the destination character array dst. |
24 | This method returns the index within this string of the first occurrence of the specified substring. |
25 | This method returns the index within this string of the first occurrence of the specified substring, starting at the specified index. |
26 | This method inserts the string representation of the boolean argument into this sequence. |
27 | This method inserts the string representation of the char argument into this sequence. |
28 | This method inserts the string representation of the char array argument into this sequence. |
29 | This method inserts the string representation of a subarray of the str array argument into this sequence. |
30 | This method inserts the specified CharSequence into this sequence. |
31 | This method inserts a subsequence of the specified CharSequence into this sequence. |
32 | This method inserts the string representation of the double argument into this sequence. |
33 | This method inserts the string representation of the float argument into this sequence. |
34 | This method inserts the string representation of the second int argument into this sequence. |
35 | This method inserts the string representation of the long argument into this sequence. |
36 | This method inserts the string representation of the Object argument into this character sequence. |
37 | This method inserts the string into this character sequence. |
38 | This method returns the index within this string of the rightmost occurrence of the specified substring. |
39 | This method returns the index within this string of the last occurrence of the specified substring. |
40 | This method returns the length (character count). |
41 | This method returns the index within this sequence that is offset from the given index by codePointOffset code points. |
42 | This method replaces the characters in a substring of this sequence with characters in the specified String. |
43 | This method causes this character sequence to be replaced by the reverse of the sequence. |
44 | Character at the specified index is set to ch. |
45 | This method sets the length of the character sequence. |
46 | This method returns a new character sequence that is a subsequence of this sequence. |
47 | This method returns a new String that contains a subsequence of characters currently contained in this character sequence. |
48 | This method returns a new String that contains a subsequence of characters currently contained in this sequence. |
49 | This method returns a string representing the data in this sequence. |
50 | This method attempts to reduce storage used for the character sequence. |
Methods inherited
This class inherits methods from the following classes −
java.lang.Object
java.lang.CharSequence