If you are familiar with C, C++ control statements then it will be easier for you to understand the control statements here and if not then also it will be easier to understand 😉
So let’s have a closer look.
JAVA has three types of control statements:
- Selection Statement
- Iteration Statement
- Jump Statement
In Selection Statement, if you want your program to follow different paths of execution based on the outcome of the expression or the condition, then selection statements will be used. to understand better follow this example of flow chart.
To understand better follow this example of flow chart:
Here, if you have only one or two paths then you can use if else statement, and for multiple branching, you can use switch case .
In Iteration Statement, you can repeatedly execute the same set of instructions until the condition satisfies. This will create a loop. These also create loops.
Here, have a look at the flow chart of loop, that would explain you the concept:
In Jump Statement, you can transfer the control to another part of your program. JAVA mainly has three jump statements:
break, continue and return.
In C you might have learnt about goto statement. goto statement is not supported in JAVA.