Does anyone have any help with this error?
error: incompatible types: Object cannot be converted to String
I am passing a HashMap
into a function with the intention of iterating through its keyset and storing them into a list for ordering, here is my code
public HashMap mapReorder(HashMap map) {
/* Clear the list ready for input */
mapList.clear();
/* Iterate through the keys in the map */
for(String keys : map.keySet()) {
double mapKey = keys.getValue();
mapList.add(mapKey);
}
/* Sorting the order by ascending value (Internal Frequency Rank) */
Collections.sort(mapList);
/* Populating HashMap with ordered list */
for(double frequencies : mapList) {
orderedMap.put(keys , frequencies);
}
return null;
}