-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSem2_T3_19.java
More file actions
19 lines (19 loc) · 763 Bytes
/
Copy pathSem2_T3_19.java
File metadata and controls
19 lines (19 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.*;
// Hashtable
// in this class there is a combination of Key-Value. -> called as entry.
// both key & value are objects.
// Duplicate keys are not-allowed but values can be duplicate.
// Insertion order is not preserve, it's based on HashCode of the Key-Object,
// null insertion is not-allow, not as key as well value.
public class Sem2_T3_19 {
public static void main(String[] args) {
Hashtable<Integer, String> h = new Hashtable<>();
h.put(2, "xyz");
h.put(3, "abc");
h.put(1, "RR");
// h.put(null, "xy"); // RE
// h.put(55, null); // RE
// Exception in thread "main" java.lang.NullPointerException
System.out.println(h); // {3=abc, 2=xyz, 1=RR}
}
}