如何将子字符串连接重构为StringBuilder
?
String line = "this is my start and my end string";
int start = line.indexOf("start");
line = line.substring(0, start) + line.substring(start + 5);
int end = line.indexOf("end");
line = line.substring(0, end) + line.substring(end + 3);
//result: this is my and my string";
使用 StringBuilder 时,相同的代码会是什么样子?当我想一个接一个地多次执行子字符串时?