目录

StringBuffer append(int i)

描述 (Description)

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

声明 (Declaration)

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

public StringBuffer append(int i)

参数 (Parameters)

i - 这是int的值。

返回值 (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 int argument as string to the string buffer
      buff.append(10);
      // print the string buffer after appending
      System.out.println("After append = " + buff);
      buff = new StringBuffer("abcd ");
      System.out.println("buffer = " + buff);
      // appends the int argument as string to the string buffer
      buff.append(253);
      // print the string buffer after appending
      System.out.println("After append = " + buff);
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

buffer = tuts
After append = tuts 10
buffer = abcd
After append = abcd 253
↑回到顶部↑
WIKI教程 @2018