在下面的代码示例中,将函数转换为使用 StringBuilder 会使其更高效且值得吗?和
如何将 convertStringToInputString 函数转换为使用 StringBuilder?StringBuilder 没有替换方法。
// converts String to type of String that can be inserted into database, no space, no eof characters
public String convertStringToInputString(String standardString){
String str = standardString.replace(" ", "XspaceX");
String str2 = str.replace("\n", "XendoflineX");
return str2;
}
// fills table with information to be put into JSON String object
public void fillTable(){
initialField.a[0] = convertStringToInputString("");
initialField.a[1] = convertStringToInputString("");
initialField.a[2] = convertStringToInputString("");
initialField.a[3] = convertStringToInputString("");
initialField.a[4] = convertStringToInputString("");
initialField.a[5] = convertStringToInputString("");
initialField.a[6] = convertStringToInputString("");
initialField.a[7] = convertStringToInputString("");
initialField.a[8] = convertStringToInputString("");
initialField.a[9] = convertStringToInputString("");
// continue with more 120 more lines like this