java.lang.StringBuffer.append(boolean b) 方法追加布林引數序列到字串的表示形式。
以下是java.lang.StringBuffer.append()方法的宣告
public StringBuffer append(boolean b)
b -- 這是布林值。
該方法返回一個參照物件。
NA
下面的例子顯示java.lang.StringBuffer.append()方法的使用。
package com.yiibai; import java.lang.*; public class StringBufferDemo { public static void main(String[] args) { StringBuffer buff = new StringBuffer("tuts "); System.out.println("buffer = " + buff); // appends the boolean argument as string to the string buffer buff.append(true); // print the string buffer after appending System.out.println("After append = " + buff); buff = new StringBuffer("abcd "); System.out.println("buffer = " + buff); // appends the boolean argument as string to the string buffer buff.append(false); // print the string buffer after appending System.out.println("After append = " + buff); } }
讓我們來編譯和執行上面的程式,這將產生以下結果:
buffer = tuts After append = tuts true buffer = abcd After append = abcd false