Skip to content

Commit

Permalink
iteration of hashmap key and values
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankush1oo8 committed Mar 13, 2024
1 parent f7c126c commit 49f0257
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Hashing/iterationOnHashmaps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package Hashing;
import java.util.*;
public class iterationOnHashmaps {
public static void main(String[] args) {
HashMap<String,Integer>h=new HashMap<>();
h.put("India", 100);
h.put("China", 200);
h.put("US", 50);
h.put("Japan", 10);
h.put("Germany", 20);

//iteration
Set<String> keys=h.keySet();
// System.out.println(keys);
for (String k : keys) {
System.out.println("keys: "+k+" ,values: "+h.get(k));
}

}
}

0 comments on commit 49f0257

Please sign in to comment.