Java Reference
In-Depth Information
Control Statements
There three types of statements in java.
1.
Selection statements
2.
Iteration statements
3.
Jump statements
Selection statements
•
It is to manage the flow of programs that is to be executed based on the dy-
namic conditions which can be only realized during the run time.
•
It provides flexibility.
If statement-
It provides different paths for execution of program.
Syntax
If (condition provided) statement a;
Else
Statement b;
This means if the condition is true, then statement
a
is executed but if false then statement
b
is executed.
For example
int a, b;
If (x < y) a=0;
Else
b=0;
Now there is one type of procedure using if statement
i.e.
nested if statement and it is very
common method in programming world.
For example
If (a == 10) {
If (b < 15) i = j;
If (c > 50) p = q;