HashMap最快的遍历方法

package cn.ys.testcollections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;


public class TestMap {


public static void main(String[] args) {
Map<Integer,String> map = new HashMap<Integer,String>(); 
map.put(1, "Tassel");
map.put(2, "叶苏");
map.put(3, "黄海");

Iterator it = map.entrySet().iterator();
while(it.hasNext()){
Map.Entry<Integer,String>  e = (Map.Entry<Integer, String>)it.next();
Object key = e.getKey();
Object value = e.getValue();
System.out.println("key:"+key+" value:"+value);
}
}
}

猜你喜欢

转载自blog.csdn.net/qq_38983577/article/details/79720439