filmov
tv
Java Flow Control - Conditional and Loop Statements

Показать описание
Java Flow Control Statements, Java Conditional and Loop Statements, if condition, else if ,nested if and switch statement. Java for loop, while loop, do while loop, and enhanced for loop.
Conditional statements within loops and Loops within conditions.
i) Java Conditional Statements
ii) Java Loop Statements
----------------------------------------------------
Usage of Conditional Statements
1) Execute a Block of statements when condition is true
2) Execute a block of statements when a compound condition is true
3) Execute a block of statements when condition is true otherwise execute another block of statements
4) Decide among several alternates (else if)
5) Execute a block of statements when more than one condition is true
6) Decide among several alternates (using switch statement)
---------------------------------------------------
Java Loop Statements
Four Loop structures in Java
1) for loop
2) while loop
3) do while loop
4) enhanced for loop
-----------------------------------
1) for loop
Description: It repeats a block of statements for a specified number of times.
2) while loop
Description: It repeats a block of statements while condition is true
3) do while loop
Description: It repeats a block of statements while condition is true
Note: It executes statements at least once irrespective of the condition
4) Enhance for loop
Description: It executes all elements in an Array
------------------------------------------------------
We can use,
a) Only Conditions
b) only Loops
c) Condition/s within Loop/s
d) Loop/s within Condition/s
-----------------------------------------------------
Conditional statements within loops and Loops within conditions.
i) Java Conditional Statements
ii) Java Loop Statements
----------------------------------------------------
Usage of Conditional Statements
1) Execute a Block of statements when condition is true
2) Execute a block of statements when a compound condition is true
3) Execute a block of statements when condition is true otherwise execute another block of statements
4) Decide among several alternates (else if)
5) Execute a block of statements when more than one condition is true
6) Decide among several alternates (using switch statement)
---------------------------------------------------
Java Loop Statements
Four Loop structures in Java
1) for loop
2) while loop
3) do while loop
4) enhanced for loop
-----------------------------------
1) for loop
Description: It repeats a block of statements for a specified number of times.
2) while loop
Description: It repeats a block of statements while condition is true
3) do while loop
Description: It repeats a block of statements while condition is true
Note: It executes statements at least once irrespective of the condition
4) Enhance for loop
Description: It executes all elements in an Array
------------------------------------------------------
We can use,
a) Only Conditions
b) only Loops
c) Condition/s within Loop/s
d) Loop/s within Condition/s
-----------------------------------------------------
Комментарии