[go: up one dir, main page]

0% found this document useful (0 votes)
15 views4 pages

Looping Statement

Hbbuijj

Uploaded by

daveibanez24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Looping Statement

Hbbuijj

Uploaded by

daveibanez24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Looping Statement

Looping in programming languages is a feature that facilitates the execution of a set of


instructions/functions repeatedly while some condition evaluates to true.

Types of looping statements in Java:


The Java for loop repeats the execution of a set of Java statements. A for loop executes a
block of code as long as some condition is true. The syntax to use for the loop is given
below.

The initialization expression initializes the loop and is executed only once at the beginning
when the loop begins. The termination condition is evaluated in every loop and if it
evaluates to false, the loop is terminated. And lastly, increment/decrement expression is
executed after each iteration through the loop.
While Loop in Java:
The while statement or loop continually executes a block of statements while a particular
condition is true. The while statement continues testing the expression and executing its
block until the expression evaluates to false. The syntax to use while loop in java is given
below.
Do-while Loop in Java:
The difference between do-while and while is that do-while evaluates its expression at the
bottom of the loop instead of the top. Therefore, the statements within the do block are
always executed at least once.

Note that the do-while statement ends with a semicolon. The condition expression must be
a boolean expression. The syntax to use the do-while loop is given below.

You might also like