android关于HashMap<String, Integer>取最大的value,并找出key。
来源:互联网 发布:中日军机对峙知乎 编辑:程序博客网 时间:2024/05/21 09:45
HashMap<String, Integer> map = new HashMap<String, Integer>();
Iterator iter = map.entrySet().iterator();
int num = 1;
HashMap<String, Integer> tempMap = new HashMap<String, Integer>(1);String tempKey = null;
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
int val = (Integer) entry.getValue();
if(val<100)
{
if(tempMap != null && tempKey != null){
if(val < tempMap.get(tempKey)) {
tempKey = key;
tempMap.put(key, val);
}
}
if(tempKey == null){
tempKey = key;
tempMap.put(key, val);
}
num = Math.max(val, num);
}
}
最大的value为num,对应的key为tempKey
0 0
- android关于HashMap<String, Integer>取最大的value,并找出key。
- 取list<Integer,String> list的key和value
- 关于hashMap的key和value的理解
- Android 遍历Hashmap里面的key 和value
- 关于HashMap根据Value获取Key
- (转)关于HashMap根据Value获取Key
- 找出一个数组中重复次数最多的字符暨找出Map中的最大Value及其对应的Key
- Java HashMap使用String,Long,Integer作为key的性能测试
- new HashMap(){{put(key, value);}}的解释
- HashMap遍历 key value
- js取object的key与value
- HashMap和HashTable,HashMap中key和value的原理
- HashMap和HashTable,HashMap中key和value的原理
- HashMap和HashTable,HashMap中key和value的原理
- Java 关于HashMap根据value反向获取key值
- Java 关于HashMap根据value反向获取key值
- C# key取value
- 谨慎使用String作为HashMap的Key
- 【搜索】 HDU 1226 超级密码
- QT MVC 模式
- Java代码实现二叉搜索树-----插入
- dns服务器测试工具:queryperf
- uva108
- android关于HashMap<String, Integer>取最大的value,并找出key。
- HDU 1001 Sum Problem
- Nginx 日志文件切割
- 【数据结构与算法 03】直接插入排序
- tomcat jndi加密
- java运行jar中单个程序
- Win内存分配函数(GlobalAlloc/HeapAlloc/LocalAlloc/VirtualAlloc)
- 银行会消失吗?
- 异常:No persister for的解决办法