Skip to content

循环中拼接字符串 #182

Open
Open
@QiAnXinCodeSafe

Description

@QiAnXinCodeSafe

String s = "";
if (array != null) {
if (split == null) {
split = ",";
}
for (int i = 0; i < array.length; i++) {
if (ignoreEmptyItem && isEmpty(array[i], true)) {
continue;
}
s += ((i > 0 ? split : "") + array[i]);
}
}

String numberString = "";
String single;
for (int i = 0; i < s.length(); i++) {
single = s.substring(i, i + 1);
if (isNumer(single)) {
numberString += single;
} else {
if (onlyStart) {
return numberString;
}
}
}

String correctPrice = "";
String s;
for (int i = 0; i < price.length(); i++) {
s = price.substring(i, i + 1);
if (".".equals(s) || isNumer(s)) {
correctPrice += s;
}
}

建议在循环中使用StringBuilder拼接字符串

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions