HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 129 The Hashtable class

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * See also color IMAGE

This class is similar to the Perl associative array (or hash array with {} brackets). It can store a set of key and 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 things of type Object and you must cast the result.
  • steve = (Employee) staff.get("149-26-7355");
If there was no entry, a null is returned.
Performance of the Hashtable can also be affected by giving an initialCapacity and a loadFactor for reallocation.



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Feb 18 1997