Array comparison using '==', instead of 'Arrays.equals()'
Reports operators ==
and !=
used to test for array equality. In most cases, testing for the equality of array contents is intended, which can be done with the java.util.Arrays.equals()
method.
A quick-fix is suggested to replace ==
with java.util.Arrays.equals()
.
Example:
void foo(Object[] x, Object[] y) {
boolean comparison = x == y;
}
After the quick-fix is applied:
void foo(Object[] x, Object[] y) {
boolean comparison = Arrays.equals(x, y);
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023