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. |
Hashtable staff = new Hashtable(); |
Employee harry = new Employee("Harry Hacker"); |
staff.put( "987-98-9996", harry ); |
Values are retrieved by indexing with a key. Like Vectors, Hashtables only store objects of type Object, so you must cast the result: |
steve = (Employee) staff.get("149-26-7355"); |
If there is no entry, a null value is returned. |
Performance of the Hashtable can be affected by giving an initialCapacity and a loadFactor for reallocation. |