Java Control Flow of Statements
Java Control statements control the order of execution in a java program, based on data values and conditional logic. Control the order of execution in a java program. if an expression alter the sequence of execution is called control flow. control statement are used to change the flow of execution. We use control statements when we want to change the default sequential order of execution. There are three main categories of control flow statements:
- Selection Statements:Selection statement allows the program to choose any one path from different set of paths of execution.
- if Statement
- if-else Statement
- Nested if-else Statement
- if-else-if Statement
- switch case Statement
- Loop/Iteration Statements:Looping is a process by which we can repeat a single statement or a group of statements n number of times.
- for Loop
- while Loop
- do-while Loop
- for each Loop
- Transfer/Jump Statements:Jump statements can be used to modify the behavior of conditional and iterative statements. Jump statements allow you to exit a loop, start the next iteration of a loop, or explicitly transfer program control to a specified location in your program.
- break
- continue
- Labeled break
- Labeled continue
- return