mirror of
https://github.com/namibia/awesome-cheatsheets.git
synced 2024-11-24 21:57:38 +00:00
Updated java.md
Updated java.md Added the enhanced for loop/for-each with example.
This commit is contained in:
parent
78022a5e95
commit
1836f22a54
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user