Java Control Flow Statements

In this tutorial you will learn about the Java Control Flow Statements and its application with practical example.

Java Control Flow Statements

Control flow or flow of control is the order in which instructions, statements, and functions call are being executed or evaluated when a program is running. The control flow statements are also called Flow Control Statements. In Java, statements inside your code are generally executed sequentially from top to bottom, in the order that they appear. It is not always the case for your program statements to be executed straightforwardly one after another sequentially, you may require to execute or skip a certain set of instructions based on condition, jump to another statement, or execute a set of statements repeatedly. In Java, control flow statements are used to alter, redirect, or control the flow of program execution based on the application logic.

Java Control Flow Statement Types

In Java, Control flow statements are mainly categorized into the following types –

java-control-flow-statements

Java Selection Statements

In Java, Selection statements allow you to control the flow of the program during the run time on the basis of the outcome of an expression or state of a variable. Selection statements are also referred to as Decision-making statements. Selection statements evaluate single or multiple test expressions which result in “TRUE” or “FALSE”. The outcome of the test expression/condition helps to determine which block of the statement(s) to execute if the condition is “TRUE” or “FALSE” otherwise.

In Java, we have the following selection statements –

Java Iteration Statements

In Java, Iteration statements are used to execute the block of code repeatedly for a specified number of times or until it meets a specified condition. Iteration statements are commonly known as loops or looping statements.

In Java, we have the following iteration statements available-

Java Jump Statements

Jump statements are used to alter or transfer the control to other sections or statements in your program from the current section.

In Java, we have the following types of jump statements –

All of the above jump statements cause different types of jumps.

 

In this tutorial we have learn about the Java Control Flow Statements and its application with practical example. I hope you will like this tutorial.