实现equals和hashCode最显而易见的作用是()
A、比较两个对象标识符的值
B、比较数据库的两条数据
C、比较两个组建是否部署在同一个应用服务器上
D、对象与字段的映射
A、比较两个对象标识符的值
B、比较数据库的两条数据
C、比较两个组建是否部署在同一个应用服务器上
D、对象与字段的映射
A、 无法确定 B、 public boolean equals(Object o) { Sock s = (Sock) o;return size.equals(s.size); } C、 public boolean equals(Object o) { Sock s = (Sock) o;return color.equals(s.color); } D、 public boolean equals(Object o) { Sock s = (Sock) o;return size.equals(s.size) &&color.equals(s.color); }
A、 无法确定 B、 public boolean equals(Object o) { Sock s = (Sock) o; return size.equals(s.size);} C、 public boolean equals(Object o) { Sock s = (Sock) o; return color.equals(s.color);} D、 public boolean equals(Object o) { Sock s = (Sock) o; return size.equals(s.size) &&color.equals(s.color); }
A、 If the hashCode values are different, the objects might be equal. B、 If the hashCode values are the same, the object must be equal. C、 If the hashCode values are the same, the objects might be equal. D、 If the hashCode values are different, the objects must be unequal.
A、public int hashCode() { return 343; } B、public int hashCode() { return size.hashCode (); } C、public int hashCode() { return color.hashCode (); } D、public int hashCode() { return (int) (Math.random() * 1000);
A、除了构建器外,不要使用和类名相同的方法名 B、使用equals()比较两个类的值是否相同 C、不要使用嵌套赋值,即在一个表达式中使用多个= D、重载equals()方法时,不必要重载hashCode()方法
A、 return super.hashCode(); B、 return name.hashCode() + age * 7; C、 return name.hashCode() + comment.hashCode() /2; D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;