Preface Though I have used Java programme language for almost a year, I'm not familiar with a notion 'hash'. I have gotten a little knowledge about hash recently because I am reading a book of algorithm, which introduce the hash function and so on. S…
Part I:equals() (javadoc) must define an equivalence relation (it must be reflexive, symmetric, and transitive). In addition, it must be consistent (if the objects are not modified, then it must keep returning the same value). Furthermore, o.equals(n…
package com.hash; import java.util.HashMap; public class Apple { private String color; public Apple(String color) { this.color = color; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((color == nul…