Java StringBuffer append()方法

java.lang.StringBuffer.append(long lng) 方法追加long参数到序列的字符串表示形式。

1 语法

public StringBuffer append(long lng)

2 参数

lng :这是一个long值。

3 返回值

该方法返回一个此对象引用。

4 示例 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * Java StringBuffer append()方法
 */
import java.lang.*;

public class StringBufferDemo {

  public static void main(String[] args) {
  
    StringBuffer buff = new StringBuffer("tuts ");
    System.out.println("buffer = " + buff);

    // appends the long argument as string to the string buffer
    buff.append(254378L);
    // print the string buffer after appending
    System.out.println("After append = " + buff);
    
    buff = new StringBuffer("abcd ");
    System.out.println("buffer = " + buff);
    // appends the long argument as string to the string buffer
    buff.append(5234l);
    // print the string buffer after appending
    System.out.println("After append = " + buff);
  }
}

输出结果为:

buffer = tuts
After append = tuts 254378
buffer = abcd
After append = abcd 5234

 

热门文章

优秀文章