[英]What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher?
在Java 5及更高版本中迭代java.util.Map的所有键/值对的最简单方法是什么?
Assuming K
is your key type and V
is your value type: 假设
K
是您的密钥类型, V
是您的值类型:
for (Map.Entry<K,V> entry : map.entrySet()) {
K key = entry.getKey();
V value = entry.getValue();
// do stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.