2
2
.
.
1
1
.
.
4
4
S
S
t
t
a
a
t
t
e
e
m
m
e
e
n
n
t
t
s
s
-
-
C
C
o
o
n
n
d
d
i
i
t
t
i
i
o
o
n
n
a
a
l
l
I
I
n
n
f
f
o
o
Execution Flow Statements define which part of the code should be executed next
Branch Statements execute its Body single time if Condition is TRUE.
Loop Statements execute its Body multiple times while Condition is TRUE (or while iterating through Elements)
Jump Statements unconditionally skip execution of subsequent code
B
B
r
r
a
a
n
n
c
c
h
h
S
S
t
t
a
a
t
t
e
e
m
m
e
e
n
n
t
t
s
s
Branch Statements execute its Body single time if Condition is TRUE
if ... else Statement executes single section for which condition is TRUE
switch...case Statement is used instead if ... else Statement when all conditions evaluate the same variable
? TRUE : FALSE Statement executes first section if Condition is TRUE. Otherwise it executes second section.
if ... else
int value = 10;
String text = "bird";
if (value == 10 ) { System.out.println("Value = 10" ); }
else if (text.equals("bird")) { System.out.println("text equals bird"); }
else if (text.equals("dog" )) { System.out.println("text equals dog" ); }
else { System.out.println("No match found" ); }
switch...case
//TEST VARIABLES.
int a = 5;
//SWITCH STATEMENT.
switch (a) {
case 1:
System.out.println("Value is 1. Exit from switch.");
break;
case 5:
System.out.println("Value is 5. Continue to next case or default.");
default:
System.out.println("Default value is selected if no case was true.");
break;
}
VARIABLE = CONDITION ? TRUE : FALSE
//TEST VARIABLES.
int a = 10;
int b = 5;
//VARIABLE = CONDITION ? TRUE : FALSE
int max = (a > b) ? a : b;