简体   繁体   中英

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

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"));
     }
  });

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"));
     }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM