1 | This class is similar to a Perl associative array (or hash). It can store a set of key-value pairs, neither of which can be null. |
2 | Hashtable staff = new Hashtable(); |
3 | Employee harry = new Employee("Harry Hacker"); |
4 | staff.put( "987-98-9996", harry ); |
5 | Values are retrieved by indexing with a key. Like Vectors, Hashtables only store objects of type Object, so you must cast the result: |
6 | steve = (Employee) staff.get("149-26-7355"); |
7 | If there is no entry, a null value is returned. |
8 | Performance of the Hashtable can be affected by giving an initialCapacity and a loadFactor for reallocation. |