Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantStringOperation/beforeNewStringFromEntireArray.java
Andrey Cherkasov 3ec4cf4a76 RedundantStringOperationInspection: String constructor can be simplified in case the passed array copied entirely
IDEA-226130

GitOrigin-RevId: d20197f50aeceaea2074e905b94ea7d838d53b4a
2022-12-22 15:59:30 +00:00

18 lines
752 B
Java

// "Fix all 'Redundant 'String' operation' problems in file" "true"
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
class Main {
void foo(char[] chars, byte[] bytes, int[] ints) {
String s1 = new String(bytes, 0, bytes.length<caret>);
String s2 = new String(chars, 0, chars.length);
String s3 = new String(bytes, 0, bytes.length, Charset.defaultCharset());
String s4 = new String(bytes, 0, bytes.length, StandardCharsets.ISO_8859_1);
String s5 = new String(ints, 0, ints.length);
String s6 = new String(chars, 0, bytes.length);
String s7 = new String(bytes, 1, bytes.length, Charset.defaultCharset());
String s8 = new String(bytes, 0, bytes.length - 1, StandardCharsets.ISO_8859_1);
}
}