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 祝福语驱散霉运的话简短