We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be7ff42 commit 7891d52Copy full SHA for 7891d52
arrays/Enhanced_For_Loop.java
@@ -0,0 +1,31 @@
1
+package arrays;
2
+
3
+public class Enhanced_For_Loop {
4
5
+ public static void main(String[] args) {
6
7
+ int array[]={3,4,5,6,7};
8
+ int total=0;
9
10
+ for (int x: array) {
11
+ total +=x;
12
+ }
13
+ System.out.println(total);
14
15
+ /*
16
+ * Similar to last for loop
17
+ * except that you have an identifier
18
+ * so it's like saying that x = array
19
+ * and it will add:
20
+ * 1. 0 + 3
21
+ * 2. 3 + 4
22
+ * 3. 4 + 5
23
+ * 4. 5 + 6
24
+ * 5. 6 + 7
25
+ * then the output is the total, 25
26
+ */
27
28
29
30
31
+}
0 commit comments