Java takes each item in the hashmap/map

ht‮t‬ps://www.lautturi.com
Java takes each item in the hashmap/map
/**
 * @author lautturi.com
 * Java example: for loop hashmap in java
 */

import java.util.*;
import java.util.Map.Entry;

public class Lautturi {
    
	public static void main(String[] args) {
		
		Map<String, String> map = new HashMap<>();
		
		map.put("Apple", "21");
		map.put("Banana", "31");
		map.put("Cherry", "22");
		map.put("Orange", "54");

		for(Entry<String, String> entry:map.entrySet()) {
		  System.out.println("key: "+entry.getKey()+" value: "+entry.getValue());
		}

		
	}
}

output:

key: Apple value: 21
key: Cherry value: 22
key: Orange value: 54
key: Banana value: 31
Created Time:2017-09-08 14:35:55  Author:lautturi