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
Copy file name to clipboardExpand all lines: _posts/java-basic/2021-12-06-for-each-loop.md
+12-14
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,17 @@ title: "For-each loop in Java or Enhanced For loop in Java"
4
4
author: gaurav
5
5
categories: [Java, Control Flow Statements]
6
6
toc: true
7
-
description: "In this article, we will see the for-each loop in java i.e. Enhanced for loop"
7
+
description: "In this article, we will see the for-each loop in Java i.e. Enhanced for loop"
8
8
---
9
-
In this article, we will see the for-each loop in java i.e. Enhanced forloop
9
+
In this article, we will see the for-each loop in Java i.e. Enhanced for-loop
10
10
11
11
## Introduction
12
12
13
13
For-each loop is introduced in Java 1.5.
14
14
15
15
It provides a better approach to traversing the array or collection.
16
16
17
-
In a simple for loop, we initialize the variable and write the condition for that variable. But in for each loop, we do not have to initialize a variable or write any condition for that.
17
+
In a simple for loop, we initialize the variable and write the condition for that variable. But in the enhanced loop, we do not have to initialize a variable or write any condition for that.
18
18
19
19
The foreach loop is always used to traverse over the array or any collection.
20
20
@@ -42,17 +42,15 @@ I have given a simple Java program to traverse over an array using the for-each
0 commit comments