By DeepSource

Do not call hashCode directly on an array class JAVA-E1044

Bug risk Autofix

Calling T[].hashCode() (where T is some class) will not take into account the contents of the array.

Use the Arrays.hashCode(Object[]) static method to calculate an array's hash code instead.

Any array type inherits the default equals() and hashCode() implementations from Object. By default, object equality works by comparing reference addresses (like a == b), and an object's hash code can also similarly depend on its address (The JVM specification leaves this at the discretion of the implementation). Make sure this is the behavior you actually want.

Bad Practice

String[] names = ...;

int namesHash = names.hashCode(); // Bad.


int namesHash = Arrays.hashCode(names);


If you actually intend to use the default hashCode implementation of arrays, you may safely ignore this issue.