CS210: Intermediate Computing/Data Structures (Java)

Lab #10


This lab gives you experience writing an application that uses the java.util.TreeMap class

Pre-Lab Assignment

Study the text, lecture notes, and the Sun Website API for the TreeMap class.


Setup an empty project in your Lab10 folder on your removable media.†† There are no files to download.

Lab Activities

Write a class named Dictionary with a main method that instantiates a TreeMap to store a String key and a String value. The key should be a String containing a single word and the value should be a String that contains its definition. The ordering should be the natural ordering of the keys by the String class compareTo method.


Call the appropriate TreeMap methods to add three key-values pairs of your own choosing.(You can be as creative in selecting words and definitions as you wish Ö or not!)


Call the appropriate method to print the contents of the dictionary.


Call the appropriate method to find and print the value for one of the key words that you used.


Call the same method for a key word that you did not use and print the result.


Call the appropriate method to delete one of the key-value pairs that you used.


Call the appropriate method to verify that the value for that key can no longer be found and print a result showing that.


Since this is the last week of the semester, there will be no written report for this lab due next week.Show your code and a sample run to the TA to get credit for doing this lab.


If I donít see you before the end of the semester/finals week, have a Happy Holiday Season.