forked from solvery/lang-features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhash_1.java
More file actions
33 lines (26 loc) · 829 Bytes
/
Copy pathhash_1.java
File metadata and controls
33 lines (26 loc) · 829 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
import java.util.*;
public class hash_1 {
public static void main(String[] args) {
{
// TreeMap<String, Integer> m = new TreeMap<String, Integer>();
// Map<String, Integer> m = new TreeMap<String, Integer>();
// Map<String, Integer> m = new HashMap<String, Integer>();
// Map<String, Integer> m = new WeakHashMap<String, Integer>();
// Map<String, Integer> m = new Hashtable<String, Integer>();
Map<String, Integer> m = new WeakHashMap<String, Integer>();
m.put("foo", 2);
m.put("hello", 5);
m.get("hello");
m.size();
m.remove("hello");
Iterator<String> it = m.keySet().iterator();
String first = it.next();
System.out.println(first);
for ( Map.Entry<String, Integer> e : m.entrySet() ) {
e.getKey();
e.getValue();
}
System.out.println(m);
}
}
}