elibraryportal Logo

Loops in Java

In programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true.

Typs of Loop.

There are 3 types of loops in Java that is......

  1. for loop
  2. while loop
  3. do-while loop

For Loop

for is a keyword in Java programming language. for loop is used to repeat the execution of the statements until a certain condition holds.

Syntax:

OR

Flow Chart :-

For Loop of Java

First step:- In for loop, initialization value first and only one time, which means that the initialization part of for loop only executes once.

Second step:-Condition in for loop is evaluated on each iteration, if the condition is true then the statements inside for loop body gets executed. Once the condition returns false, the statements in for loop does not execute and the control gets transferred to the next statement in the program after for loop.


Example 1 :- Table Print Program

Output

For Loop Example in Java

Example 2 :- Table Print Program by the User input in java

Output

For Loop Table Example in Java

Example 3 :- Print Multiplication table of any number in java use for loop.

Output

For Loop Table Multiple Example in Java