public class StringBuilder extends Object implements CharSequence, Appendable
StringBufferImpl
that is chosen with deferred binding.
Most methods will give expected performance results. Exceptions are
setCharAt(int, char)
, which is O(n), and length()
, which
forces a toString()
and thus should not be used many times on the
same StringBuilder
.
This class is an exact clone of StringBuffer
except for the name. Any
change made to one should be mirrored in the other.Constructor and Description |
---|
StringBuilder() |
StringBuilder(CharSequence s) |
StringBuilder(int ignoredCapacity)
This implementation does not track capacity; using this constructor is
functionally equivalent to using the zero-argument constructor.
|
StringBuilder(String s) |
Modifier and Type | Method and Description |
---|---|
StringBuilder |
append(boolean x) |
StringBuilder |
append(char x) |
StringBuilder |
append(char[] x) |
StringBuilder |
append(char[] x,
int start,
int len) |
StringBuilder |
append(CharSequence x) |
StringBuilder |
append(CharSequence x,
int start,
int end) |
StringBuilder |
append(double x) |
StringBuilder |
append(float x) |
StringBuilder |
append(int x) |
StringBuilder |
append(long x) |
StringBuilder |
append(Object x) |
StringBuilder |
append(String x) |
StringBuilder |
append(StringBuffer x) |
StringBuilder |
appendCodePoint(int x) |
int |
capacity()
This implementation does not track capacity; always returns
Integer.MAX_VALUE . |
char |
charAt(int index) |
StringBuilder |
delete(int start,
int end) |
StringBuilder |
deleteCharAt(int start) |
void |
ensureCapacity(int ignoredCapacity)
This implementation does not track capacity; calling this method has no
effect.
|
void |
getChars(int srcStart,
int srcEnd,
char[] dst,
int dstStart) |
int |
indexOf(String x) |
int |
indexOf(String x,
int start) |
StringBuilder |
insert(int index,
boolean x) |
StringBuilder |
insert(int index,
char x) |
StringBuilder |
insert(int index,
char[] x) |
StringBuilder |
insert(int index,
char[] x,
int offset,
int len) |
StringBuilder |
insert(int index,
CharSequence chars) |
StringBuilder |
insert(int index,
CharSequence chars,
int start,
int end) |
StringBuilder |
insert(int index,
double x) |
StringBuilder |
insert(int index,
float x) |
StringBuilder |
insert(int index,
int x) |
StringBuilder |
insert(int index,
long x) |
StringBuilder |
insert(int index,
Object x) |
StringBuilder |
insert(int index,
String x) |
int |
lastIndexOf(String s) |
int |
lastIndexOf(String s,
int start) |
int |
length() |
StringBuilder |
replace(int start,
int end,
String toInsert) |
StringBuilder |
reverse() |
void |
setCharAt(int index,
char x)
Warning! This method is much slower than the JRE implementation.
|
void |
setLength(int newLength) |
CharSequence |
subSequence(int start,
int end) |
String |
substring(int begin) |
String |
substring(int begin,
int end) |
String |
toString() |
void |
trimToSize() |
public StringBuilder()
public StringBuilder(CharSequence s)
public StringBuilder(int ignoredCapacity)
public StringBuilder(String s)
public StringBuilder append(boolean x)
public StringBuilder append(char x)
append
in interface Appendable
public StringBuilder append(char[] x)
public StringBuilder append(char[] x, int start, int len)
public StringBuilder append(CharSequence x)
append
in interface Appendable
public StringBuilder append(CharSequence x, int start, int end)
append
in interface Appendable
public StringBuilder append(double x)
public StringBuilder append(float x)
public StringBuilder append(int x)
public StringBuilder append(long x)
public StringBuilder append(Object x)
public StringBuilder append(String x)
public StringBuilder append(StringBuffer x)
public StringBuilder appendCodePoint(int x)
public int capacity()
Integer.MAX_VALUE
.public char charAt(int index)
charAt
in interface CharSequence
public StringBuilder delete(int start, int end)
public StringBuilder deleteCharAt(int start)
public void ensureCapacity(int ignoredCapacity)
public void getChars(int srcStart, int srcEnd, char[] dst, int dstStart)
public int indexOf(String x)
public int indexOf(String x, int start)
public StringBuilder insert(int index, boolean x)
public StringBuilder insert(int index, char x)
public StringBuilder insert(int index, char[] x)
public StringBuilder insert(int index, char[] x, int offset, int len)
public StringBuilder insert(int index, CharSequence chars)
public StringBuilder insert(int index, CharSequence chars, int start, int end)
public StringBuilder insert(int index, double x)
public StringBuilder insert(int index, float x)
public StringBuilder insert(int index, int x)
public StringBuilder insert(int index, long x)
public StringBuilder insert(int index, Object x)
public StringBuilder insert(int index, String x)
public int lastIndexOf(String s)
public int lastIndexOf(String s, int start)
public int length()
length
in interface CharSequence
public StringBuilder replace(int start, int end, String toInsert)
public StringBuilder reverse()
public void setCharAt(int index, char x)
public void setLength(int newLength)
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public String substring(int begin)
public String substring(int begin, int end)
public String toString()
toString
in interface CharSequence
toString
in class Object
public void trimToSize()
Copyright © 2018. All rights reserved.