Code /* Coll2.java David Klick CIS 260 2/8/06 This program demonstrates a few features of the HashMap class. Note that the datatypes could easily have been reversed within the program so that we were looking up Integers based on String values. */ import java.util.*; public class Coll2 { public static void main(String[] args) { HashMap hm = new HashMap(); hm.put(31, "Sally Ford"); hm.put(17, "John Buick"); hm.put(96, "Edna Honda"); hm.put(14, "Bob Chevrolet"); hm.put(22, "Jack Lotus"); hm.put(10, "Henry Toyota"); Collection coll = hm.values(); for (String s : coll) System.out.println(" " + s); for (int i=0; i<=50; i++) { String s = hm.get(i); if (s != null) { System.out.println(i + ": " + s); hm.remove(i); } } coll = hm.values(); for (String s : coll) System.out.println(" " + s); } } /* Sample output: John Buick Edna Honda Sally Ford Bob Chevrolet Henry Toyota Jack Lotus 10: Henry Toyota 14: Bob Chevrolet 17: John Buick 22: Jack Lotus 31: Sally Ford Edna Honda */