Java StringBuffer append()方法
java.lang.StringBuffer.append(float f) 方法追加float参数到这个序列的字符串表示形式。
1 语法
public StringBuffer append(float f)
2 参数
f : 浮点float值。
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 float argument as string to the string buffer
buff.append(6.5f);
// print the string buffer after appending
System.out.println("After append = " + buff);
buff = new StringBuffer("abcd ");
System.out.println("buffer = " + buff);
// appends the float argument as string to the string buffer
buff.append(10.25f);
// print the string buffer after appending
System.out.println("After append = " + buff);
}
}
输出结果为:
buffer = tuts
After append = tuts 6.5
buffer = abcd
After append = abcd 10.25
热门文章
优秀文章