You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Print array elements using enhanced for-each loop
🧠 Logic:
- Declare an integer array with predefined values.
- Use a for-each loop to iterate through each element.
- Print each element directly without using index-based access.
Signed-off-by: Somesh diwan <[email protected]>
Copy file name to clipboardExpand all lines: Section8LoopAB/src/ForLoopAB4.java
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,14 @@ public static void main(String[] args) {
10
10
}
11
11
12
12
/*
13
-
The for-each loop (also known as the enhanced for loop) in Java is used to traverse elements of arrays or collections in a simplified and readable way.
14
-
It eliminates the need for managing an index manually and works well when you just need to access each element, rather than modifying the array or list.
13
+
The for-each loop (also known as the enhanced for loop) in Java is used to traverse elements of
14
+
arrays or collections in a simplified and readable way.
15
+
16
+
It eliminates the need to manage an index manually and works well when you just need to access each element,
0 commit comments