public class StringBuffer 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 StringBuffer
.
This class is an exact clone of StringBuilder
except for the name.
Any change made to one should be mirrored in the other.Constructor and Description |
---|
StringBuffer() |
StringBuffer(CharSequence s) |
StringBuffer(int ignoredCapacity)
This implementation does not track capacity; using this constructor is
functionally equivalent to using the zero-argument constructor.
|
StringBuffer(String s) |
Modifier and Type | Method and Description |
---|---|
StringBuffer |
append(boolean x) |
StringBuffer |
append(char x) |
StringBuffer |
append(char[] x) |
StringBuffer |
append(char[] x,
int start,
int len) |
StringBuffer |
append(CharSequence x) |
StringBuffer |
append(CharSequence x,
int start,
int end) |
StringBuffer |
append(double x) |
StringBuffer |
append(float x) |
StringBuffer |
append(int x) |
StringBuffer |
append(long x) |
StringBuffer |
append(Object x) |
StringBuffer |
append(String x) |
StringBuffer |
append(StringBuffer x) |
int |
capacity()
This implementation does not track capacity; always returns
Integer.MAX_VALUE . |
char |
charAt(int index) |
StringBuffer |
delete(int start,
int end) |
StringBuffer |
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) |
StringBuffer |
insert(int index,
boolean x) |
StringBuffer |
insert(int index,
char x) |
StringBuffer |
insert(int index,
char[] x) |
StringBuffer |
insert(int index,
char[] x,
int offset,
int len) |
StringBuffer |
insert(int index,
CharSequence chars) |
StringBuffer |
insert(int index,
CharSequence chars,
int start,
int end) |
StringBuffer |
insert(int index,
double x) |
StringBuffer |
insert(int index,
float x) |
StringBuffer |
insert(int index,
int x) |
StringBuffer |
insert(int index,
long x) |
StringBuffer |
insert(int index,
Object x) |
StringBuffer |
insert(int index,
String x) |
int |
lastIndexOf(String s) |
int |
lastIndexOf(String s,
int start) |
int |
length() |
StringBuffer |
replace(int start,
int end,
String toInsert) |
StringBuffer |
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 StringBuffer()
public StringBuffer(CharSequence s)
public StringBuffer(int ignoredCapacity)
public StringBuffer(String s)
public StringBuffer append(boolean x)
public StringBuffer append(char x)
append
in interface Appendable
public StringBuffer append(char[] x)
public StringBuffer append(char[] x, int start, int len)
public StringBuffer append(CharSequence x)
append
in interface Appendable
public StringBuffer append(CharSequence x, int start, int end)
append
in interface Appendable
public StringBuffer append(double x)
public StringBuffer append(float x)
public StringBuffer append(int x)
public StringBuffer append(long x)
public StringBuffer append(Object x)
public StringBuffer append(String x)
public StringBuffer append(StringBuffer x)
public int capacity()
Integer.MAX_VALUE
.public char charAt(int index)
charAt
in interface CharSequence
public StringBuffer delete(int start, int end)
public StringBuffer 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 StringBuffer insert(int index, boolean x)
public StringBuffer insert(int index, char x)
public StringBuffer insert(int index, char[] x)
public StringBuffer insert(int index, char[] x, int offset, int len)
public StringBuffer insert(int index, CharSequence chars)
public StringBuffer insert(int index, CharSequence chars, int start, int end)
public StringBuffer insert(int index, double x)
public StringBuffer insert(int index, float x)
public StringBuffer insert(int index, int x)
public StringBuffer insert(int index, long x)
public StringBuffer insert(int index, Object x)
public StringBuffer 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 StringBuffer replace(int start, int end, String toInsert)
public StringBuffer 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.