1. 程式人生 > >遍歷List集合中的Map集合:

遍歷List集合中的Map集合:

首先遍歷list集合,在list集合中在遍歷map集合。
這裡使用到增強for,和Iterator迭代器迴圈map集合。
map集合:有多種遍歷方式(百度搜一下),這裡由於業務需求使用了迭代器Iterator,
直接上碼~~~

List<Map<String, Object>> findItemAdd = salaryDao.findItemAdd();
		//遍歷list
		for (Map<String, Object> map : findItemAdd) {
			// 遍歷map
			Iterator<Entry<String, Object>> it = map.entrySet().iterator();
			while (it.hasNext()) {
				Map.Entry<String, Object> entry = it.next();
				 System.out.println("key: " + entry.getKey() + " ~~~ value: " +
				 entry.getValue());
			}
		}

常用map集合遍歷:百度很多
map遍歷