mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
[java-inspection] StringConcatenationInLoops preview-friendly & fixed toString in null-safe mode
GitOrigin-RevId: b545a5a7acb3daa45b6aa4f675c819fefd70c350
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9ca4341d7f
commit
fcec11b91c
@@ -0,0 +1,18 @@
|
||||
// "Introduce new StringBuilder to update variable 'res' (null-safe)" "true"
|
||||
public class SB {
|
||||
public static void main(String[] args) {
|
||||
StringBuilder resBuilder = null;
|
||||
for (String arg : args) {
|
||||
if (resBuilder == null) {
|
||||
resBuilder = new StringBuilder("[");
|
||||
} else {
|
||||
resBuilder.append(",");
|
||||
}
|
||||
resBuilder.append(arg);
|
||||
}
|
||||
String res = String.valueOf(resBuilder);
|
||||
res += "]";
|
||||
System.out.println(res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Introduce new StringBuilder to update variable 'res' (null-safe)" "true"
|
||||
public class SB {
|
||||
public static void main(String[] args) {
|
||||
String res = null;
|
||||
for (String arg : args) {
|
||||
if (res == null) {
|
||||
res = "[";
|
||||
} else {
|
||||
res +<caret>= ",";
|
||||
}
|
||||
res += arg;
|
||||
}
|
||||
res += "]";
|
||||
System.out.println(res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user