遍历Map

public class IteratorMap {
	public static void main(String[] args) {
		Map map = new HashMap();
		map.put("test", "test");
		map.put("name", "dahai");
		for(Iterator it = map.entrySet().iterator();it.hasNext();){
			Map.Entry entry = (Map.Entry)it.next();
			Object key = entry.getKey();
			Object val = entry.getValue();
		}
	}
}

你可能感兴趣的:(java,idea)