What Are Control Statements in a Programming Language?
Control statements form the basic entities of a structured programming language like Java. They are used to alter the flow of execution of the program.
Why do we need to alter the program flow?
The reason is “decision making”! In life, we may be given a set of options like doing “Electronics” or “Computer science”. We do make a decision by analyzing certain conditions (like our personal interest, the scope of job opportunities, etc).
With the decision we make, we alter the flow of our life’s direction. This is exactly what happens in a Java program. We use control structures to make decisions and alter the direction of program flow in one or the other path(s) available.
Control statements are one of the fundamentals required for any programming language.
Types of Control Statements
There are three types of control structures are available in Java.
1. Selection Structure(one or many branches)
2. Loop Structure(Repetition of a set of activities)
3. Jump Structure(jumps to next iteration of the loop or breaks)
The control statements are
- If Else
- Do While
- break, continue
A statement describes instructing a computer to perform some task.
Similarly, control statements in Java are a statement that determines whether other statements will be executed or not. It controls the flow of a program.
The above-defined control statements fall into three types of control structures. Below is the table showing them all.
|Selection Structures||Loop Structures||Jump Structures|