Created
June 19, 2012 10:58
-
-
Save sue445/2953530 to your computer and use it in GitHub Desktop.
Map entry sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
public class MapSample { | |
public static void main(String[] args) { | |
Map<String, Integer> map = new HashMap<String, Integer>(); | |
map.put("a", 1); | |
map.put("b", 2); | |
map.put("c", 3); | |
for(Map.Entry<String, Integer> entry : map.entrySet()){ | |
System.out.println("key=" + entry.getKey() + ", value=" + entry.getValue()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment