-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashTableDesign.java
More file actions
35 lines (26 loc) · 892 Bytes
/
Copy pathHashTableDesign.java
File metadata and controls
35 lines (26 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.HashMap;
import java.util.Map;
/* put, get, remove
* containsKey(key)
* size(), entrySet(), Entry<keyType, valueType>
* Map.Entry<keyType, valueType> e: map.entrySet() -> e.getKey(), e.getValue();
* */
public class HashTableDesign {
public static void main(String[] args) {
HashMap<String, String> h1 = new HashMap<>();
h1.put("a", "apple");
h1.put("b", "apple");
h1.put("c", "apple");
h1.put("d", "banna");
if (h1.containsKey("d"))
System.out.println("if works,");
else
System.out.println("if no works,");
// iter
for (Map.Entry<String, String> e: h1.entrySet()) {
System.out.printf("key is %s, value is %s", e.getKey(), e.getValue());
}
System.out.println(h1);
System.out.println(h1.size());
}
}