Java StringBuffer append()方法
java.lang.StringBuffer.append(int i) 方法追加int参数到此序列的字符串表示形式。
1 语法
public StringBuffer append(int i)
2 参数
i : 这是一个int值。
3 返回值
该方法返回一个此对象引用。
4 示例
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* Java StringBuffer append()方法
*/
import java.lang.*;
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("tuts ");
System.out.println("buffer = " + buff);
// appends the int argument as string to the string buffer
buff.append(10);
// print the string buffer after appending
System.out.println("After append = " + buff);
buff = new StringBuffer("abcd ");
System.out.println("buffer = " + buff);
// appends the int argument as string to the string buffer
buff.append(253);
// print the string buffer after appending
System.out.println("After append = " + buff);
}
}
输出结果为:
buffer = tuts
After append = tuts 10
buffer = abcd
After append = abcd 253
热门文章
优秀文章