目录

StringBuffer append(float f)

描述 (Description)

java.lang.StringBuffer.append(float f)方法将float参数的字符串表示形式附加到此序列。

声明 (Declaration)

以下是java.lang.StringBuffer.append()方法的声明

public StringBuffer append(float f)

参数 (Parameters)

f - 这是float的值。

返回值 (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 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
↑回到顶部↑
WIKI教程 @2018