![]() |
Help: The Hashtable Class
Help is available for each task, or you can go straight to the solution source code.
Click on the Company class in the Magelang/JavaBasics package from the Workspace window. Add "import java.util.Hashtable" and "import java.util.Enumeration" before the class Company {...} declaration (in the bottom pane). Task 2Replace the array with a Hashtable in the Company class. Use Employee as both the key and value.Change the type of the employees variable to Hashtable. Remove the array brackets. Initialize the Hashtable to have 10 entries. Modify the addEmployee method to use the Hashtable method put. Task 3Rewrite the findEmployee method to use the Hashtable for the search.Use the Hashtable method get. Task 4Rewrite the findEmployeeNamed method to enumerate through the Hashtable to do the search.Use the Enumeration class to iterate through the Hashtable, as shown in the course notes. Task 5Rewrite the toString method of the Company class to use the Hashtable.Enumerate through the Hashtable as in the task above. Task 6Run the program via the HashTest class. |
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |