by
0
6
2,563
1
Top 1% !
Popular
Famous
Easy-to-find
Specified
MultiPlatform
Popularity: 7173rd place
Languagejava
LicenseMIT_X11

How to create a Java HashMap and iterate through keys and values

This is how to simply create a templated Map, using HashMap and loop through its keys and values
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/466017/How-to-create-a-Java-HashMap-and-iterate?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
final Map<String, Object> myMap = new HashMap<String, Object>(); myMap.put("key1", "true"); myMap.put("key2", "123"); for (Map.Entry<String, Object> entry : myMap.entrySet()) { System.out.println(entry.getKey() + "/" + entry.getValue()); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus