When running the below code I get an error. I need suggestion on how to solve the error.
Map<String, String> map = new HashMap<String, String>();
map.put("test", "milan");
map.put("joo", "arsenal");
map.put("keer", "manu");
List list = new LinkedList(map.entrySet());
Collections.sort(list, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
return (((Comparable) ((Map.Entry) (o1)).getValue()).compareTo((Map.Entry) (o2)));
}
});
Error: Exception in thread "main" java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.lang.String