-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashPrograms.java
More file actions
59 lines (45 loc) · 1.85 KB
/
Copy pathHashPrograms.java
File metadata and controls
59 lines (45 loc) · 1.85 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Hash Table, Hash Map and Linked Hash Map */
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.Set;
public class HashPrograms {
public static void main(String[] args) {
Hashtable<String, String> ht = new Hashtable<String, String>();
HashMap<String, String> hm = new HashMap<String, String>();
HashMap<Integer, String> myMap = new HashMap<Integer, String>();// Q
LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();
ht.put("Microsoft", "Windows 11");
ht.put("IBM", "IBM Quantum");
ht.put("Google", "Fushia OS");
hm.put("1", "Tizen OS");
hm.put("Apple", "Mac OS");
hm.put("1", "z/OS");
lhm.put("Microsoft", "Windows 11");
lhm.put("IBM", "IBM Quantum");
lhm.put("Google", "Fushia OS");
System.out.println("Hash Table:");
System.out.println(ht);
System.out.println("- - - - - - - - - - - -");
System.out.println("Hash Map:");
System.out.println(hm);
System.out.println("- - - - - - - - - - - - -");
System.out.println("Linked Hash Map:");
System.out.println(lhm);
System.out.println("- - - - - - - - - - ");
System.out.println("Hash Table Values:");
Set<String> keys_ht = ht.keySet();
for (String s : keys_ht)
System.out.println(ht.get(s));
System.out.println("- - - - - - - - - - ");
System.out.println("Hash Map Values:");
Set<String> keys_hm = hm.keySet();
for (String s : keys_hm)
System.out.println(hm.get(s));
System.out.println("- - - - - - - - - - ");
System.out.println("Linked Hash Map Values:");
Set<String> keys_lhm = lhm.keySet();
for (String s : keys_lhm)
System.out.println(lhm.get(s));
}
}