遍歷HashMap

 HashMap和Hashtable類似,不同之處在於HashMap是非同步的,並且允許null,即null value和null key。,但是將HashMap視爲Collection時(values()方法可返回Collection),其迭代子操作時間開銷和HashMap的容量成比例。因此,如果迭代操作的性能相當重要的話,不要將HashMap的初始化容量設得過高,或者load factor過低。

Iterator<Entry<String, String>> it = attribute.entrySet().iterator();
				while(it.hasNext()){
					Map.Entry<String, String> entry = (Map.Entry<String, String>) it.next();
					String key = entry.getKey().toString();
					String value = entry.getValue().toString();
				}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章