Hi I am working on an example problem from the book that is not compiling correctly.
Here is the compiler error:
TestMap.java:6: type Map does not take parameters
Map<String, Integer> hashMap = new HashMap<String, Integer>();
TestMap.java:16: type Map does not take parameters
Map<String, Integer> treeMap =
^
TestMap.java:22: type Map does not take parameters
Map<String, Integer> linkedHashMap =
^
Here is the example code from the book:import java.util.*; public class TestMap { public static void main(String[] args) { Map<String, Integer> hashMap = new HashMap<String, Integer>(); hashMap.put("Smith", 30); hashMap.put("Anderson", 31); hashMap.put("Lewis", 29); hashMap.put("Cook", 29); System.out.println("Display entries in a HashMap"); System.out.println(hashMap); Map<String, Integer> treeMap = new TreeMap<String, Integer>(hashMap); System.out.println("Display entries in ascending order of key"); System.out.println(treeMap); Map<String, Integer> linkedHashMap = new LinkedHashMap<String, Integer>(16, 0.75f, true); linkedHashMap.put("Smith", 30); linkedHashMap.put("Anderson", 31); linkedHashMap.put("Lewis", 29); linkedHashMap.put("Cook", 29); System.out.println("The age for " + "Lewis is " + linkedHashMap.get("Lewis").intValue()); System.out.println("\nDisplay entries in a LinkedHashMap"); System.out.println(linkedHashMap); } }
I'm not sure why Map doesn't take parameters when the book and the Java Tutorials site has an example using Map<K, V>. Any help would be appreciated.