public static String getCityId(HashMap<String,String> citys, String city){
Set set = citys.entrySet();//新建一个不可重复的集合
ArrayList<String> arr = new ArrayList<String>();//新建一个集合
Iterator it = set.iterator();//遍历的类
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();//找到所有key-value对集合
if(entry.getValue().equals(city)) {//通过判断是否有该value
String s = (String) entry.getKey();//取得key
arr.add(s);
}
}
return arr.get(0);
}

相关文章:

  • 2021-10-07
  • 2023-03-22
  • 2022-12-23
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案