-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashtable
More file actions
29 lines (19 loc) · 785 Bytes
/
Hashtable
File metadata and controls
29 lines (19 loc) · 785 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
import java.util.Hashtable;
public class main {
public static void main(String[] args) {
Hashtable<Integer,String> table=new Hashtable<>();
//inside Hashtable constructors we can pass an int(capacity) and float(loadFactor)
//int is for capacity and float(e.g.0.5f(50%)) is the trigger point when the capacity will grow dynamically
//The default capacity is 11 and loadFactor is 0.75f
table.put(100,"zoro");
table.put(123,"luffy");
table.put(321,"sanji");
table.put(555,"loki");
table.put(777,"jimbei");
table.put(666,"god");
//table.remove(1222);
for(Integer key:table.keySet()){
System.out.println(key.hashCode()%11+"\t"+key+"\t"+table.get(key));
}
}
}