java.util.Objects equals/hashCode: use Arrays for array fields, ensure single array is not passed to Objects.hashCode vararg to avoid confusion (IDEA-140111)

This commit is contained in:
Anna Kozlova
2015-05-12 17:07:09 +02:00
parent fdbfd64350
commit 6a6b9f5226
5 changed files with 32 additions and 0 deletions
@@ -0,0 +1,18 @@
import java.util.Arrays;
class A {
int[] a1;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final A a = (A) o;
return Arrays.equals(a1, a.a1);
}
@Override
public int hashCode() {
return Arrays.hashCode(a1);
}
}
@@ -0,0 +1,4 @@
class A {
int[] a1;
<caret>
}