Java StringBuffer.append()
方法更新呼叫該方法的物件的值。 該方法採用:boolean
,char
,int
,long
,String
等型別。
語法
以下是每種基本資料型別的方法 -
public StringBuffer append(boolean b)
public StringBuffer append(char c)
public StringBuffer append(char[] str)
public StringBuffer append(char[] str, int offset, int len)
public StringBuffer append(double d)
public StringBuffer append(float f)
public StringBuffer append(int i)
public StringBuffer append(long l)
public StringBuffer append(Object obj)
public StringBuffer append(StringBuffer sb)
public StringBuffer append(String str)
StringBuffer
中附加的內容。StringBuffer
物件。public class Test {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("Test");
sb.append(" String Buffer");
System.out.println(sb);
}
}
執行上面範例程式碼,得到以下結果:
Test String Buffer