import java.util.*; public class JavaMapAndDictionary { public static void main(String[] args) { // Map Example double[] mapGPA = new double[] { 4.0, 3.0, 2.0, 1.0, 0.0 }; char[] mapLetter = new char[] { 'A', 'B', 'C', 'D', 'F' }; Map map = new HashMap(); for (int i = 0; i < mapGPA.length; i++) { map.put(mapLetter[i], mapGPA[i]); // Insert key/value into map } for (Character key : map.keySet()) { System.out.println(key + " " + map.get(key)); } // END: Map Example System.out.println(); // Dictionary Example double[] dictGPA = new double[] { 4.0, 3.0, 2.0, 1.0, 0.0 }; char[] dictLetter = new char[] { 'A', 'B', 'C', 'D', 'F' }; Dictionary dictionary = new Hashtable(); for (int i = 0; i < dictGPA.length; i++) { dictionary.put(dictLetter[i], dictGPA[i]); // Insert key/value into map } for (Enumeration keys = dictionary.keys(); keys.hasMoreElements(); ) { char keyVal = keys.nextElement(); System.out.println(keyVal + " " + dictionary.get(keyVal)); } // END: Dictionary Example } }