Inspectopedia Help

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

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Java, 241.16690

Last modified: 29 April 2024