So I want to use TreeMap with a customized comparator My key is a String: id, my value is an int: count; I NEED TO COMPARE THE COUNT, AS THE VALUE(INTEGER) IN THE TREEMAP So I have:
In one class:
import java.util.*;
public TreeMap<String, Integer> tm = new TreeMap<String, Integer>(new SortIdCount<Integer>());
In another class:
import java.util.Comparator;
public class SortIdCount implements Comparator<Integer>{
public int compare(Integer count1, Integer count2) {
return count1.compareTo(count2);
}
}
It shows error in eclipse:
The type SortIdCount is not generic; it cannot be parameterized with arguments <Integer>