在上一篇的基础上HashMap重写(2)HashMap重写toString()方法,增加get()方法。
上代码:
/**
* get()方法
* @param key
* @return
*/
public Object get(Object key) {
//拿到对应的hash值
int hash = myHash(key.hashCode(), table.length);
Object value = null;
if (table[hash] != null) {
Node2 temp = table[hash];