mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
28 lines
680 B
HTML
28 lines
680 B
HTML
<html>
|
|
<body>
|
|
Reports implementations of <code>equals()</code> that access
|
|
non-<code>final</code> variables. Such access may result in <code>equals()</code>
|
|
returning different results at different points in the object's lifecycle, which may in turn cause problems when
|
|
using the standard collections classes.
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
public class Person {
|
|
private String lastName;
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
...
|
|
Person other = (Person) obj;
|
|
if (lastName == null) {
|
|
if (!lastName.equals(other.lastName)) {
|
|
return false;
|
|
...
|
|
}
|
|
}
|
|
}
|
|
</code>
|
|
</pre>
|
|
<!-- tooltip end -->
|
|
|
|
</body>
|
|
</html> |