Control Statements in Java

Programming languages use control statements to control the flow of execution of the program. With the help of control statements, programming languages execute the code according to the condition. Like other programming languages, Java also uses control statements to control the flow of execution of the program.

Java control statements can be divided into three categories: Selection or Decision making, Looping or Iteration, and Jump.

1. Selection or Decision Making statements

Selection or Decision-making statements decide whether a particular line or block of code will execute or not based on the result of an expression or value of a variable. It will check a condition, and the result will be a Boolean value, such as true or false. If the result is true, then the code will be executed, and if the result is false, then the code will not be executed. Java has two types of decision making statements.

  • if  statements
  • switch statement
2. Iteration or Looping statements

Iteration or Looping statements enable a program to execute a line or a block of code repeatedly as long as a condition is true. Java has following loops.

  • do while loop
  • while loop
  • for loop
  • for-each loop
3. Jump statements

Jump statements enable the Program to jump to specific statements. It means, Program will run in a nonlinear way. Java has two jump statements.

  • break statement
  • continue statement