Skip to content

Commit

Permalink
hashmpa iteration methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed-Farazuddin committed Mar 29, 2024
1 parent 46d88b8 commit 9a08bb4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/HashMaps/functions/Iteration.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Iteration {
public static void main(String[] args) {
Expand All @@ -12,5 +13,12 @@ public static void main(String[] args) {
for(Map.Entry<Integer,Integer> e : map.entrySet()){
System.out.println(e.getKey() + " : " + e.getValue());
}

// Method 2 of iteration

Set<Integer> set =map.keySet();
for(int key : set){
System.out.println(key + " : " + map.get(key));
}
}
}

0 comments on commit 9a08bb4

Please sign in to comment.