本文实例讲述了java遍历hashmap简单的方法。分享给大家供大家参考。具体实现方法如下:
import java.util.hashmap;
import java.util.iterator;
import java.util.set;
public class hashsettest {
public static void main(string[] args) {
hashmap map = new hashmap();
map.put("a", "aa");
map.put("b", "bb");
map.put("c", "cc");
map.put("d", "dd");
map.put("e", "ee");
set set = map.keyset();
for(iterator itr=set.iterator();itr.hasnext();){
string value =(string) itr.next();
string key = (string)map.get(value);
system.out.println(value+"="+key);
}
}
}
希望本文所述对大家的java程序设计有所帮助。
更多java遍历hashmap简单的方法。