Member-only story

Loops in Java

For Loops, While Loop & Do-While Loop

Nipuni Arunodi
3 min readDec 19, 2020
Photo by Timo Volz on Unsplash

There are two kinds of loops,

  • Finite loop: The statements in the block may be executed any number of times from zero to an infinite number
  • Infinite loop: A loop that continues forever.

A loop consists of;

  • Body of loop
  • Control statement

Loop Control Structures

Entry control loop

  • If the condition is not the satisfied body of the loop is never executed.

Exit Control loop

  • The body of the loop is executed unconditionally for the 1 st time.

Loop Control Structures

  • The while loop
  • The do-while loop
  • The for loop

while Loop

initialization;
while(condition){…

--

--

Responses (1)