php    php100   android
当前位置:首页 » java.lang包 »

Java.lang.StringBuffer.append(CharSequence s)方法实例

评论  编辑

描述

The java.lang.StringBuffer.append(CharSequence s) method appends the specified CharSequence to this sequence.The characters of the CharSequence argument are appended, in order, increasing the length of this sequence by the length of the argument.

声明

Following is the declaration for java.lang.StringBuffer.append() method

public StringBuffer append(CharSequence s)

参数

  • s -- This is the CharSequence to append.

返回值

This method returns a reference to this object.

异常

  • NA

实例一

编辑 +分享实例

以下例子将告诉你如何使用 java.lang.StringBuffer.append() method.

package gitbook.net;

import java.lang.*;

public class StringBufferDemo {

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

    CharSequence cSeq = "online";
    // appends the CharSequence
    buff.append(cSeq);

    // print the string buffer after appending
    System.out.println("After append = " + buff);
  }
}

编译和执行以上程序,将得到以下的结果:

buffer = compile
After append = compile online

贡献/合作者

正在开放中...
 

评论(条)

  • 还没有评论!