Control Flow Statements in Java
Control Flow Statements
Direct program execution based on conditions and repetitions.
Complete Example
if (age >= 18) {
System.out.println("Adult");
} else if (age >= 13) {
System.out.println("Teen");
} else {
System.out.println("Child");
}
for (int i = 1; i <= 5; i++) {
System.out.println(i);
}Key Points
if-else if-elsefor multiple conditions.switchfor multiple discrete values.- Loops: for, while, do-while, enhanced for-each.
breakexits loop,continueskips iteration.