document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /**
  2.  * @author Timotius Wirawan
  3.  * @version 27 Oktober 2020
  4.  */
  5.  
  6.  import java.util.*;
  7.  class HashMapContoh
  8.  {
  9.      public static void main(String args[])
  10.      {
  11.          //membuat hashmap
  12.          HashMap<Integer,String> hm=new HashMap<Integer,String>();
  13.          
  14.          //input objek
  15.          hm.put(100,"Kano");
  16.          hm.put(101,"Laila");
  17.          hm.put(102,"Badu");
  18.          hm.put(null, "Johan");
  19.          
  20.          //menampilkan isi
  21.          for(Map.Entry m:hm.entrySet())
  22.          {
  23.              System.out.println(m.getKey()+" "+m.getValue());
  24.          }
  25.      }
  26.  }
');