Return | Method | Summary |
---|---|---|
StringBuffer | append(boolean b) | Appends the boolean argument to the sequence. |
StringBuffer | append(char c) | Appends the char argument to this sequence. |
StringBuffer | append(char[] str) | Appends the char array argument to this sequence. |
StringBuffer | append(char[] str, int offset, int len) | Appends a subarray of the char array argument to this sequence. |
StringBuffer | append(CharSequence s) | Appends the CharSequence to this sequence. |
StringBuffer | append(CharSequence s, int start, int end) | Appends a subsequence of the CharSequence to this sequence. |
StringBuffer | append(double d) | Appends the double argument to this sequence. |
StringBuffer | append(float f) | Appends the float argument to this sequence. |
StringBuffer | append(int i) | Appends the int argument to this sequence. |
StringBuffer | append(long lng) | Appends the long argument to this sequence. |
StringBuffer | append(Object obj) | Appends the Object argument. |
StringBuffer | append(String str) | Appends this character sequence. |
StringBuffer | append(StringBuffer sb) | Appends the StringBuffer to this sequence. |
StringBuffer | appendCodePoint(int codePoint) | Appends the codePoint argument to this sequence. |
StringBuffer | insert(int offset, boolean b) | Inserts the boolean argument into this sequence. |
StringBuffer | insert(int offset, char c) | Inserts the char argument into this sequence. |
StringBuffer | insert(int offset, char[] str) | Inserts the char array argument into this sequence. |
StringBuffer | insert(int index, char[] str, int offset, int len) | Inserts a subarray of the str array argument into this sequence. |
StringBuffer | insert(int dstOffset, CharSequence s) | Inserts CharSequence into this sequence. |
StringBuffer | insert(int dstOffset, CharSequence s, int start, int end) | Inserts a subsequence of the specified CharSequence into this sequence. |
StringBuffer | insert(int offset, double d) | Inserts the double argument into this sequence. |
StringBuffer | insert(int offset, float f) | Inserts the float argument into this sequence. |
StringBuffer | insert(int offset, int i) | Inserts the second int argument into this sequence. |
StringBuffer | insert(int offset, long l) | Inserts the long argument into this sequence. |
StringBuffer | insert(int offset, Object obj) | Inserts the Object argument into this character sequence. |
StringBuffer | insert(int offset, String str) | Inserts str. |
public class Main {
public static void main(String[] argv) {
StringBuffer sb = new StringBuffer();
sb.append(true);
sb.append("java2s.com");
sb.append(1.2);
sb.append('a');
System.out.println(sb.toString());
}
}
The output:
truejava2s.com1.2a
public class Main {
public static void main(String[] argv) {
StringBuffer sb = new StringBuffer();
sb.append(true);
sb.append("java2s.com");
sb.append(1.2);
sb.append('a');
sb.insert(3,"JAVA@S.COM");
System.out.println(sb.toString());
}
}
The output:
truJAVA@S.COMejava2s.com1.2a
String.valueOf( ) is called for each parameter to obtain its string representation.
The buffer itself is returned by each version of append( ).
This allows subsequent calls to be chained together, as shown in the following example:
public class Main {
public static void main(String args[]) {
String s;
int a = 42;
StringBuffer sb = new StringBuffer(40);
s = sb.append("a = ").append(a).append("!").toString();
System.out.println(s);
}
}
The output of this example is shown here:
a = 42!
The following sample program inserts strings:
public class Main {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("java2s.com");
sb.insert(2, "like ");
System.out.println(sb);
}
}
The output of this example is shown here:
jalike va2s.com
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |