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

貢獻/合作者

正在開放中...
 

評論(條)

  • 還冇有評論!