Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public boolean containsKey(K key) {
  2.         if (key == null) {
  3.             throw new IllegalArgumentException();
  4.         }
  5.  
  6.         int slotIndex = key.hashCode() % capacity;
  7.         TableEntry<K, V> current = table[slotIndex];
  8.         System.out.println();
  9.  
  10.         if (current.getKey().equals(null)) {
  11.             return false;
  12.        
  13.         } else {
  14.  
  15.             while (current.next != null) {
  16.                 if (current.getKey().equals(key)) {
  17.                     return true;
  18.                 } else {
  19.                     current = current.next;
  20.                 }
  21.             }
  22.  
  23.             return false;
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement