Inspectopedia
 
2024.3

'hashCode()' called on array

Warning
New
Last modified: 03 December 2024

Reports incorrect hash code calculation for arrays.

In order to correctly calculate the hash code for an array, use:

  • Arrays.hashcode() for linear arrays

  • Arrays.deepHashcode() for multidimensional arrays

These methods should also be used with Objects.hash() when the sequence of input values includes arrays, for example: Objects.hash(string, Arrays.hashcode(array))