Control Flow in Java Programing

Java control statements cause the flow of execution to advance and branch based on the changes to the state of the program.

Control statements are divided into three groups:

Control Flow in Java Programing
Control Flow in Java Programing


  1.  Selection statements allow the program to choose different parts of the execution based on the outcome of an expression
  2.  Iteration statements enable program execution to repeat one or more statements
  3.  Jump statements enable your program to execute in a non-linear fashion

Selection Statements:

Java selection statements allow to control the flow of program‘s execution based upon conditions known only during run-time.

Java provides four selection statements:

  1.  if
  2.  if-else
  3.  if-else-if
  4.  switch
Iteration Statements Java iteration statements enable repeated execution of part of a program until a certain termination condition becomes true.Java provides three iteration statements:

  1.  while
  2.  do-while
  3.  for
 Syntax for While:
while(Condition)
{

        i++
}
Syntax for While:
do{
            i++
                                  }while(condition);

Jump Statements Java jump statements enable transfer of control to other parts of program.Java provides three jump statements:

  1. break
  2. continue
  3. return

In addition, Java supports exception handling that can also alter the control flow of a program.