在Java ConcurrentHashMap中对值进行排序 [英] Sorting the values in a java ConcurrentHashMap
本文介绍了在Java ConcurrentHashMap中对值进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码用于对ConcurrentHashMap进行排序:
I have the following code for sorting a ConcurrentHashMap:
ConcurrentHashMap<String,String> text = new ConcurrentHashMap<String,String>();
....
List<String> list = new ArrayList<String>(text.values());
Collections.sort(list);
哪个抛出NoSuchElementException:
Which throws a NoSuchElementException:
Caused by: java.util.NoSuchElementException
at library.ArrayList$Itr.next(ArrayList.java:1232)
at library.ArrayList$ListItr.next(ArrayList.java:1263)
at java.util.Collections.sort(Collections.java:120)
我不知道为什么.有什么想法吗?
And I can't work out why. Any ideas?
推荐答案
查看全文