Tutorialslot.com

youtube facebook twitter gmail pinterest

For loop In Java


It executes repeatedly until the specified condition in the given expression becomes false.It has three parts;initialization,condition,increment/decrement.The initialization statement starts it's execution as the loop begins. The condition statement is evaluated each time before the execution of the given expression.The increment/decrement statement is used to increase or decrease the given value based on the given condition.

Syntax:
for(initialization ; condition ; increment/decrement)
{

  statements;

}

Example:
class ForLoop
{
public static void main(String[] args)
{
   for(int i=1; i<6; i++)
  {
     System.out.println(i+"*5="+i*5);
   }
}
}

Output:
1*5=5
2*5=10
3*5=15
4*5=20
5*5=25
6*5=30



Advertisement Powered By Google Adsense






IF YOU LIKE THIS TUTORIALS PLEASE SHARE

Share on whatsapp

POPULAR TAGS

Java java tutorials learn java java programming tutorial learn java online learning java professionals tutorials Multithreading Generics Object Oriented Language Methods Polymorphism Inheritance