java.lang.StringBuffer.append(float f) 方法追加float引數到這個序列的字串表示形式。
以下是java.lang.StringBuffer.append()方法的宣告
public StringBuffer append(float f)
f -- 浮點float值。
該方法返回一個此物件參照。
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 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