方法一:
Map<String,String> hashmp = ne HashMap();
hashmp.put("aa", "111");
hashmap.containsKey("xxx");
方法二: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;
}
方法三: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();
}