Which two statements are true about the hashCode method? (Choose two.)
A. The hashCode method for a given class can be used to test for object equality and object inequality for
that class.
B. The hashCode method is used by the java.util.SortedSet collection class to order the elements within
that set.
C. The hashCode method for a given class can be used to test for object inequality, but NOT object
equality, for that class.
D. The only important characteristic of the values returned by a hashCode method is that the distribution
of values must follow a Gaussian distribution.
E. The hashCode method is used by the java.util.HashSet collection class to group the elements within
that set
into hash buckets for swift retrieval.
Answer: CE 选C对吗?jdk的规范上明确说,不相等的两个对象,不必hashcode也不一样,尽管实践中都是不同的。
A. The hashCode method for a given class can be used to test for object equality and object inequality for
that class.
B. The hashCode method is used by the java.util.SortedSet collection class to order the elements within
that set.
C. The hashCode method for a given class can be used to test for object inequality, but NOT object
equality, for that class.
D. The only important characteristic of the values returned by a hashCode method is that the distribution
of values must follow a Gaussian distribution.
E. The hashCode method is used by the java.util.HashSet collection class to group the elements within
that set
into hash buckets for swift retrieval.
Answer: CE 选C对吗?jdk的规范上明确说,不相等的两个对象,不必hashcode也不一样,尽管实践中都是不同的。
当然你可以让俩个对象的Hashcode不相等,然后在重写equal的时候让这两个对象不等,但是这样做是不合理的