开发的这段时间,遇到过不同的一些接口,有些接口比较严谨,需要参数字典升序进行加密,因此编写了以下这个方法进行排序,采用存入map的方式,对他的key进行字典升序排列,返回有顺序的list。

 

public static List getCode(Map map){
    List list = new ArrayList();
    Iterator iter = map.entrySet().iterator();  //获得map的Iterator
      while(iter.hasNext()) {
        Entry entry = (Entry)iter.next();
        list.add(entry.getKey());
      }
    Collections.sort(list);
    return list;
}

 

随后可通过遍历list的下标,拿出值即可。

相关文章:

  • 2022-02-18
  • 2022-01-17
  • 2022-12-23
  • 2022-01-05
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2022-03-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案