Search code examples
javacompiler-errorstreemap

"TreeMap does not take parameters" Compilation Error


This is my code:

import java.util.*;
public class TreeMap {
    public static void main(String[] args) {
        Map<String,Integer> treemap = new TreeMap<String,Integer>();
        Some code to fill the treemap ie treemap.put("Kevin", 36);
    }
}

And I am getting this compiler error:

TreeMap.java:5: error: type TreeMap does not take parameters
   Map<String,Integer> treemap = new TreeMap<String,Integer>();
                                            ^

Solution

  • Use full qualified class name for the Java TreeMap class

    new java.util.TreeMap<String,Integer>()