Answers:
Jesper的回答很好。另一种解决方案是使用TreeMap(您要求其他数据结构)。
TreeMap<String, String> myMap = new TreeMap<String, String>();
String first = myMap.firstEntry().getValue();
String firstOther = myMap.get(myMap.firstKey());
TreeMap有开销,因此HashMap更快,但仅作为替代解决方案的一个示例。
firstEntry()方法未在界面中定义,SortedMap而仅在TreeMapand ConcurrentSkipListMap:(
SortedMap因为它有firstKey()方法。