Returns whether this map contains the specified key. @param key the key to search for. @return true if this map contains the specified key, false otherwise.
(Object key)
| 59 | * {@code false} otherwise. |
| 60 | */ |
| 61 | public boolean containsKey(Object key) { |
| 62 | Iterator<Map.Entry<K, V>> it = entrySet().iterator(); |
| 63 | if (key != null) { |
| 64 | while (it.hasNext()) { |
| 65 | if (key.equals(it.next().getKey())) { |
| 66 | return true; |
| 67 | } |
| 68 | } |
| 69 | } else { |
| 70 | while (it.hasNext()) { |
| 71 | if (it.next().getKey() == null) { |
| 72 | return true; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Returns whether this map contains the specified value. |