1
1
mirror of https://github.com/namibia/awesome-cheatsheets.git synced 2024-11-22 04:45:16 +00:00

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

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.