Skip to content

Commit 07f6b02

Browse files
committed
feat: Use enhanced for-loop to iterate over a List of integers
🧠 Logic: - Created an `ArrayList<Integer>` and added five integers (1 to 5). - Used an enhanced for-loop (`for-each`) to iterate through the list. - Printed each element during iteration, showcasing how lists are traversed in Java using clean syntax. Signed-off-by: Somesh diwan <[email protected]>
1 parent 29d1968 commit 07f6b02

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Section8LoopAB/Loop 2.O/src/ForLoopList.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ public static void main(String[] args) {
1111
numbers.add(5);
1212

1313
//Iterating through the list using for each loop
14-
15-
for (int number : numbers){
14+
for (int number : numbers) {
1615
System.out.println(number);
1716
}
1817
}

0 commit comments

Comments
 (0)