×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Added: May 5, 2021 4:33 PM
Views: 4003
Tags: collections
  1.     public static void main(String[] args) {
  2.  
  3.         HashMap<Integer,String> hash_map= new HashMap<Integer,String>();
  4.         hash_map.put(1, "Red");
  5.         hash_map.put(2, "Green");
  6.         hash_map.put(3, "Black");
  7.         hash_map.put(4, "White");
  8.         hash_map.put(5, "Blue");
  9.  
  10.         for (Map.Entry x:hash_map.entrySet()){
  11.             System.out.println(x.getKey()+ " " + x.getValue());
  12.         }
  13.  
  14.     }
  15. }