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 厂庆祝福语大全简短