-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHashTable.java
35 lines (27 loc) · 875 Bytes
/
HashTable.java
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.*;
public class HashTable {
static void log(Object o)
{
System.out.print(o);
}
static void logln(Object o)
{
System.out.println(o);
}
public static void main(String[] args) {
Hashtable<String, String> licenplates = new Hashtable<>();
Enumeration people;
String output;
licenplates.put("David", new String("6543ML"));
licenplates.put("Tracy", new String("6UN274"));
licenplates.put("Bob", new String("37KU42"));
//Retrieve All License Plates
people = licenplates.keys();
while(people.hasMoreElements()) {
output = (String) people.nextElement();
System.out.println(output + ": " + licenplates.get(output));
}
//Outputs the number of elements within the hashtable
logln(licenplates.size());
}
}