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
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西