The type new Comparator(){} must implement the inherited abstract method Comparator.compare(Object, Object)

StackOverflow https://stackoverflow.com/questions/21900376

  •  14-10-2022
  •  | 
  •  

Question

please help her. I had an error in

  Collections.sort(var4, new Comparator() {
     public int compare(TreeMap var1, TreeMap var2) {
        return ((String)var1.get("col_3")).compareTo((String)var2.get("col_3"));
     }
  });
Was it helpful?

Solution

Try this way by adding to Comparator ,

Collections.sort(var4, new Comparator<TreeMap>() 
{
     public int compare(TreeMap var1, TreeMap var2) 
     {
        return ((String)var1.get("col_3")).compareTo((String)var2.get("col_3"));
     }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top