Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Map;
- /**
- * Collection dengan
- * Hash map
- *
- * @author Thomasdwi.a
- * @version 20201025
- */
- public class hashMapContoh {
- public static void main (String [] args){
- HashMap<Integer, String> hm = new HashMap<Integer, String>();
- hm.put(101,"anwar");
- hm.put(102,"Amir");
- hm.put(103,"Amos");
- hm.put(null,"Zo");
- for (Map.Entry m : hm.entrySet()) {
- System.out.println(m.getKey()+" "+m.getValue());
- }
- }
- }
- /** Output:
- * null Zo
- * 101 anwar
- * 102 Amir
- * 103 Amos
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement