StringBuffer append()方法在Java中做什么?
StringBufferappend()方法将特定参数的String表示形式附加到序列中。它是java.lang.StringBuffer类的方法。此方法返回对该对象的引用。
append()方法的基本语法如下-
public StringBuffer append(data_type variable_name)
append()给出了说明方法使用的程序,如下所示-
示例
import java.lang.*;
public class Example {
public static void main(String[] args) {
StringBuffer s1 = new StringBuffer("The sun rises in the east ");
System.out.println("Statement : " + s1);
s1.append(true);
System.out.println("Outcome : " + s1+"\n");
StringBuffer s2 = new StringBuffer("Hello ");
System.out.println("Statement : " + s2);
s2.append("World");
System.out.println("Output: " + s2+"\n");
char c = 'A';
StringBuffer s3 = new StringBuffer("Apple starts with ");
System.out.println("Statement : " + s3);
s3.append(c);
System.out.println("Output : " + s3);
}
}输出结果
Statement : The sun rises in the east Outcome : The sun rises in the east true Statement : Hello Output: Hello World Statement : Apple starts with Output : Apple starts with A
热门推荐
1 带狗狗训练
4 听力训练狗狗
6 怎训练狗狗
7 腹肌训练狗狗
8 网球训练狗狗
9 记叙文训练狗狗
10 狗狗太凶怎么训练
11 核心力量训练狗狗
12 狗狗乱叫怎么训练
13 发音训练狗狗
14 怎么训练狗狗叼东西给主人
15 荆州训练狗狗
16 篮球训练狗狗
17 做训练狗狗
18 训练狗狗坐姿