Java
Redundant array length check
Warning
New
Last modified: 03 December 2024Reports unnecessary array length checks followed by array iteration. When array length is zero, the iteration will be skipped anyway, so there's no need to check length explicitly.
Example:
void f(String[] array) {
if (array.length != 0) { // unnecessary check
for (String str : array) {
System.out.println(str);
}
}
}
A quick-fix is suggested to unwrap or remove the length check:
void f(String[] array) {
for (String str : array) {
System.out.println(str);
}
}
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
RedundantLengthCheck
New in 2022.3
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Java, 243.23126 |
Thanks for your feedback!
Was this page helpful?