Java如何将字符串插入StringBuffer?
package org.nhooo.example.lang;
public class StringBufferInsert {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer("kodeava");
System.out.println("Text before = " + sb.toString());
//“e”字母。还有其他的重载版本|k|o|d|e|a|v|a|...。
//“e”字母。还有其他的重载版本0|1|2|3|4|5|6|7|...
//
//“e”字母。还有其他的重载版本从上面的序列中,您可以看到
//“e”字母。还有其他的重载版本字符串从0开始,所以当我们在
//“e”字母。还有其他的重载版本第四个偏移量,表示它将在
//“e”字母。还有其他的重载版本"e" letter. There are other overload version of this
//“e”字母。还有其他的重载版本method that can be used to insert other type of data such
//“e”字母。还有其他的重载版本as char, int, long, float, double, Object, etc.
sb.insert(4, "j");
System.out.println("After first insert = " + sb.toString());
//“e”字母。还有其他的重载版本Here we insert a string to the StringBuffer at index 8
sb.insert(8, " examples");
System.out.println("Final result = " + sb.toString());
}
}该程序将打印以下输出:
Text before = kodeava After first insert = nhooo Final result = nhooo examples
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志