HashMap 的containsKey(Objec…

  •  /a**
         * Returns true if this map contains a mapping for the
         * specified key.
         *
         * @param   key   The key whose presence in this map is to be tested
         * @return true if this map contains a mapping for the specified
         * key.
         */


  •     public boolean containsKey(Object key) {
            Object k = maskNull(key);
            int hash = hash(k.hashCode());
            int i = indexFor(hash, table.length);
            Entry e = table[i];
            while (e != null) {
                if (e.hash == hash && eq(k, e.key))
                    return true;
                e = e.next;
            }
            return false;
        }

你可能感兴趣的:(HashMap 的containsKey(Objec…)