Inspectopedia
 
2024.3

Non-final field referenced in 'hashCode()'

Warning
New
Last modified: 03 December 2024

Reports implementations of hashCode() that access non-final variables.

Such access may result in hashCode() returning different values at different points in the object's lifecycle, which may in turn cause problems when using the standard collections classes.

Example:

A quick-fix is suggested to make the field final: