我需要根据
同时,我需要键随着值的排序自动排序,或者可以说键和值是绑在一起的,因此值的任何更改都应反映在键中。
HashMap
内存储的值来对其进行排序。该 HashMap
包含在电话中存储的联系人姓名。同时,我需要键随着值的排序自动排序,或者可以说键和值是绑在一起的,因此值的任何更改都应反映在键中。
HashMap<Integer,String> map = new HashMap<Integer,String>();
map.put(1,"froyo");
map.put(2,"abby");
map.put(3,"denver");
map.put(4,"frost");
map.put(5,"daisy");
所需输出:
2,abby;
5,daisy;
3,denver;
4,frost;
1,froyo;