求出map排序后第二个位置的key和value
public class TestMap9 {
public static void main(String[] args){
List list1=new ArrayList();
List list2=new ArrayList();
List list3=new ArrayList();
Map map2=new TreeMap();
Map map=new HashMap();
map.put("b", 6);
map.put("a", 7);
map.put("c", 2);
Iterator ite=map.entrySet().iterator();
while(ite.hasNext()){
Entry entry=(Entry)ite.next();
list1.add(entry.getKey());
Collections.sort(list1);
list2.add(entry.getValue());
Collections.sort(list2);
}
for(int i=0;i<map.size();i++){
map2.put(list1.get(i), list2.get(i));
}
Iterator itet=map2.entrySet().iterator();
while(itet.hasNext()){
Entry entry=(Entry)itet.next();
list3.add(entry.getKey());
}
System.out.println(list3.get(1)+"/"+map2.get(list3.get(1)));
}
}