Java??HashMap?????????
???????????? ???????[ 2012/10/29 10:48:13 ] ????????
/**
* Returns the value to which the specified key is mapped??
* or {@code null} if this map contains no mapping for the key.
*
* <p>More formally?? if this map contains a mapping from a key
* {@code k} to a value {@code v} such that {@code (key==null ? k==null :
* key.equals(k))}?? then this method returns {@code v}; otherwise
* it returns {@code null}. (There can be at most one such mapping.)
*
* <p>A return value of {@code null} does not <i>necessarily</i>
* indicate that the map contains no mapping for the key; it's also
* possible that the map explicitly maps the key to {@code null}.
* The {@link #containsKey containsKey} operation may be used to
* distinguish these two cases.
*
* @see #put(Object?? Object)
*/
public V get(Object key) {
if (key == null)
return getForNullKey();
int hash = hash(key.hashCode());
for (Entry<K??V> e = table[indexFor(hash?? table.length)];
e != null;
e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k)))
return e.value;
}
return null;
}
??????????????put()????????????if (e.hash == hash && ((k = e.key) == key || key.equals(k)))??
????
?洢Entry???????????????????Entry?????table???顣
??????????????????λ?ó??bucket??????????????????LinkedList?????????????
Key?????hashCode()???????????Entry?????洢λ?á?
Key?????equals()??????????????Map?ж???????
get()??put()??????Value?????hashCode??equals????????
null??hashCode????0????????Entry??????????洢???????????λ??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11