Map Iteration

By ukmodak | March 31st 2024 10:34:01 AM | viewed 688 times

The followings method can use for map iteration:

Map map = new HashMap<>();

map.forEach((key, value) -> System.out.println("[Key] : " + key + " [Value] : " + value));
    for (Map.Entry entry : map.entrySet()) {
		System.out.println("[Key] : " + entry.getKey() + " [Value] : " + entry.getValue());
	}
   Iterator iter = map.entrySet().iterator();
	while (iter.hasNext()) {
		Map.Entry entry = (Map.Entry) iter.next();
		System.out.println("[Key] : " + entry.getKey() + " [Value] : " + entry.getValue());
	}
	

bONEandALL
Visitor

Total : 26654

Today :3

Today Visit Country :

  • France
  • United States