Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Timotius Wirawan
- * @version 27 Oktober 2020
- */
- import java.util.*;
- class HashMapContoh
- {
- public static void main(String args[])
- {
- //membuat hashmap
- HashMap<Integer,String> hm=new HashMap<Integer,String>();
- //input objek
- hm.put(100,"Kano");
- hm.put(101,"Laila");
- hm.put(102,"Badu");
- hm.put(null, "Johan");
- //menampilkan isi
- for(Map.Entry m:hm.entrySet())
- {
- System.out.println(m.getKey()+" "+m.getValue());
- }
- }
- }
Add Comment
Please, Sign In to add comment