ch6ex19.java
来自「JAVA程序设计 丁岳伟 彭敦陆编著 高等教育出版社示例代码可供JAVA初学者学」· Java 代码 · 共 24 行
JAVA
24 行
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 + =
减小字号Ctrl + -
显示快捷键?