Updated java.md

Updated java.md
Added the enhanced for loop/for-each with example.
This commit is contained in:
Sapna Katti 2021-07-17 11:15:15 +05:30
parent 78022a5e95
commit 1836f22a54
1 changed files with 18 additions and 0 deletions

View File

@ -196,6 +196,24 @@ int c = a + b;
System.out.println(i);
}
```
>Enhanced for loop/for-each
```java
for(dataType item : array) {
...
}
```
**Example:**
```java
// array of numbers
int[] numbers = {100, 200, 300, 400};
// for each loop
for (int number: numbers) {
System.out.println(number);
```
> WHILE LOOP STATEMENT
```java
while(condition){ //till condition will be true.