Control structures are the building blocks of logic flow in a program. They determine the order in which statements are executed, allowing programs to make decisions, repeat actions, or branch into different paths.

DonnaMayZuiga 7 views 26 slides Oct 19, 2025
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

control structures in java


Slide Content

Control structures in Java

Control structures in programming In programming, control structures are constructs that determine the flow of execution within a program. They enable developers to dictate the order in which statements are executed based on certain conditions or loops.

Three kinds of control structures in Java

1. Control statements in java / Conditional Branches in java Java control statements use to choose   the path for execution.

1. Control statements in java / Conditional Branches in java if statement It is a simple decision-making statement. It uses to decide whether the statement or block of statements should be executed or not.  The  if statement  always accepts the  boolean value  and performs the action accordingly. 

Example

1. Control statements in java / Conditional Branches in java nested if statement The  nested if statements  mean an  if statement  inside another  if statement .  The inner block of the  if statement  executes only if the  outer block condition  is true. This statement is useful when you want to test a dependent condition.

Example

1. Control statements in java / Conditional Branches in java if-else statement Suppose when we want to execute the same block of code if the condition is false. Here we come on the  if-else statement.   In an  if-else statement , there are two blocks one is an  if block  and another is an  else block . If a certain condition is true, then  if block  executes otherwise  else block  executes.

Example

1. Control statements in java / Conditional Branches in java if-else if statement/ ladder if statements If we want to execute the different codes based on different conditions then we can use  if-else-if.   It is known as  if-else if ladder . This statement executes from the top down. During the execution of conditions if any condition is found true, then the statement associated with that  if statement  is executed, and the rest of the code will be skipped. If none of the conditions returns true, then the final else statement executes.

Example

1. Control statements in java / Conditional Branches in java Switch statement The  switch statement in java  is like the if-else-if ladder statement. To reduce the code complexity of the  if-else-if ladder switch statement  comes. In a switch, the statement executes one from multiple statements based on condition. 

Example

2. Loops in Java / Looping statements in java The loop in java uses to iterate the instruction multiple times. When we want to execute the statement a number of times then we use loops in java.

2. Loops in Java / Looping statements in java for  loop A for loop executes the block of code several times. It means the number of iterations is fixed. JAVA provides a concise way of writing the loop structure.

Example

2. Loops in Java / Looping statements in java while loop A while loop allows code to execute repeatedly until the given condition returns true. If the number of iterations doesn’t fix, it recommends using a while loop. It is also known as an entry control loop.

Example

2. Loops in Java / Looping statements in java do-while loop It is like a while loop with the only difference being that it checks for the condition after the execution of the body of the loop. It is also known as Exit Control Loop.

Example

3. Branching Statements in Java use to  alter the flow of control in loops

3. Branching Statements in Java break If a  break statement  encounters inside a loop, the loop immediately terminates, and the control of the program goes to the next statement following the loop. It is used along with the  if statement  in  loops.  If the condition is true, then the  break statement  terminates the loop immediately.

Example

3. Branching Statements in Java continue The continue statement uses in a loop control structure. If you want to skip some code and need to jump to the next iteration of the loop immediately. Then you can use a continue statement. It can be used in for loop or a while loop.

Example
Tags