📄 stringbuffermodify.java
字号:
//例7.5
class StringBufferModify{
public static void main(String argvs[]){
StringBuffer sb = new StringBuffer("We will modify a StringBuffer ");
System.out.println("Here is a StringBuffer Let's modify it.");
System.out.println("Now the StringBuffer is \""+sb+"\"");
char c = '!';
double pi = .1415927;
int p = 3;
String a = "Pi = ";
System.out.println("append a char :"+c);
System.out.println("Now the StringBuffer is :\""+sb.append(c)+"\"");
System.out.println("insert a string :"+a);
System.out.println("Now the StringBuffer is :\""+sb.insert(sb.length(),a)+"\"");
System.out.println("append a double num :"+p);
System.out.println("Now the StringBuffer is :\""+sb.append(p)+"\"");
System.out.println("append a double num :"+pi);
System.out.println("Now the StringBuffer is :\""+sb.append(pi)+"\"");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -