We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e02450e commit 25fa3a4Copy full SHA for 25fa3a4
BasicJava/src/examples/forEachMethod.java
@@ -0,0 +1,38 @@
1
+/**
2
+ *
3
+ */
4
+package examples;
5
+
6
+import java.util.HashMap;
7
+import java.util.Map;
8
9
10
+ * @author rutpatel
11
12
13
+public class forEachMethod {
14
15
+ /**
16
+ * @param args
17
18
+ public static void main(String[] args) {
19
20
+ Map<String, Integer> items = new HashMap<>();
21
+ items.put("A", 10);
22
+ items.put("B", 20);
23
+ items.put("C", 30);
24
+ items.put("D", 40);
25
+ items.put("E", 50);
26
+ items.put("F", 60);
27
28
+ items.forEach((k, v) -> System.out.println("Item : " + k + " Count : " + v));
29
30
+ items.forEach((k, v) -> {
31
+ if ("E".equals(k)) {
32
+ System.out.println("Hello E");
33
+ }
34
+ });
35
36
37
38
+}
0 commit comments