我目前正在阅读一个文本文件,其中有200万行,这是之前问题中提到的: Java Fastest way to read through text file with 2 million lines
现在我将这些信息存储到HashMap中,然后想通过TreeMap对其进行排序,因为我想使用ceilingkey。以下方法是否正确?
private HashMap<Integer, String> hMap = new HashMap();
private TreeMap<Integer, String> tMap = new TreeMap<Integer, String>(hMap);
Collections.sort(hMap)
?Collections.sort(hMap,WITH_MY_OWN_COMPARATOR)
? - Suresh AttaCollections.sort(hMap)
不起作用,sort()
只能用于 List。 - Kushal