Tutorialslot.com

youtube facebook twitter gmail pinterest

do-while in java

It helps to execute the body of loop atleast once without considering whether the given condition is true or not.It checks the termination condition only at the end instaed of checking at the start of the loop.

Syntax:
do {
// body of loop
} while (condition);

Example:
class DoWhileLoop
{
public static void main(String args[])
{
   int i=13;
   do
   {
     System.out.println(i);
     i--;
   }while(i>1);
}
}

Output:
13
12
11
10
9
8
7
6
5
4
3
2



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