📄 ch6ex19.java
字号:
public class ch6ex19{
public static void main(String[] args) {
String s1="Computer";
String s = "My "+s1+" course is "+Integer.toString(87);
System.out.println(s);
// The "equivalent" using StringBuffer:
StringBuffer sb =
new StringBuffer("My "); // Creates String!
sb.append(s1);
sb.append(" course is "); // Creates String!
sb.append(Integer.toString(87));
System.out.println(sb);
//insert not after is
sb.insert(21," not");
String st=sb.toString();
System.out.println(st);
//delete the word Computer
sb.delete(3,12);
System.out.println(sb);
System.out.println("The buffer capacity is "+sb.capacity());
System.out.println("The string length is "+sb.length());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -