StringBuffer append(double d)
描述 (Description)
java.lang.StringBuffer.append(double d)方法将double参数的字符串表示形式附加到此序列。
声明 (Declaration)
以下是java.lang.StringBuffer.append()方法的声明
public StringBuffer append(double d)
参数 (Parameters)
d - 这是double的值。
返回值 (Return Value)
此方法返回对此对象的引用。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.StringBuffer.append()方法的用法。
package com.iowiki;
import java.lang.*;
public class StringBufferDemo {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("tuts ");
System.out.println("buffer = " + buff);
// appends the double argument as string to the string buffer
buff.append(30.100000001d);
// print the string buffer after appending
System.out.println("After append = " + buff);
buff = new StringBuffer("abcd ");
System.out.println("buffer = " + buff);
// appends the double argument as string to the string buffer
buff.append(20.12d);
// print the string buffer after appending
System.out.println("After append = " + buff);
}
}
让我们编译并运行上面的程序,这将产生以下结果 -
buffer = tuts
After append = tuts 30.100000001
buffer = abcd
After append = abcd 20.12