Advertisement
apl-mhd

hasMapIterator

Dec 30th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Iterator;
  5. import java.util.Set;
  6.  
  7. public class Main {
  8.  
  9.     public static void main(String[] args) {
  10.     // write your code here
  11.  
  12.         HashMap<String, Integer> hashMap = new HashMap<>();
  13.  
  14.         hashMap.put("Apel",36);
  15.         hashMap.put("Sabi", 234);
  16.         hashMap.put("Orin",33);
  17.         hashMap.put("Nawshin",45);
  18.         System.out.println(hashMap.size());
  19.  
  20.         Set keyset = hashMap.keySet();
  21.  
  22.         Iterator<String> it = keyset.iterator();
  23.  
  24.         while (it.hasNext()){
  25.  
  26.             System.out.println(hashMap.get(it.next()));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement