方法1:keySet()
HashMap hashmp = ne HashMap();
hashmp.put("aa", "111");
Set set = hashmp.keySet();
Iterator iter = set.iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
// printkey
}
// traverse
for (String key : list.get(pos).keySet() ) {
myKey = key;
}
方法2:entrySet()
HashMap map;
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Object obj = i.next();
String key = obj.toString();
}
// or
while (i.hasNext()) {
Entry entry = (java.util.Map.Entry)it.next();
entry.getkey();
entry.getValue();
}
方法1:keySet()
HashMap hashmp = ne HashMap();
hashmp.put("aa", "111");
Set set = hashmp.keySet();
Iterator iter = set.iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
// printkey
}
// traverse
for (String key : list.get(pos).keySet() ) {
myKey = key;
}
方法2:entrySet()
HashMap map;
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Object obj = i.next();
String key = obj.toString();
}
// or
while (i.hasNext()) {
Entry entry = (java.util.Map.Entry)it.next();
entry.getkey();
entry.getValue();
}