java.lang.StringBuffer.append(double d) 方法追加double引數到序列的字串表示形式。
以下是java.lang.StringBuffer.append()方法的宣告
public StringBuffer append(double d)
d -- 此是double值。
該方法返回一個此物件參照。
NA
下面的例子顯示java.lang.StringBuffer.append()方法的使用。
package com.yiibai; 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