Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
do-while Loop in Java 
 

In this section you will learn how to use the do-while statement in java.

 

do-while Loop in Java

                         

In some conditions in java, you need to run some statements and processes once at least. For that you have to use the do while loop in  after that check the condition then we use the do-while loop statement. do-while loop is same as the while loop statement but while loop checks the certain condition is first and if condition is true then statements or processes are executed otherwise all the statements written under the while loop is ignored by the interpreter but do - while loop executes all the statements first at once and then check the condition if the condition is true then all the statements are also executed in second times otherwise second times ignored all the statements.

The Syntax for the do-while loop:

    do
    {
        statements;
    }
   
while(condition);

In this example you will see how to use the do-while loop statement. The values are already given the variable n and r in the program after that it calculate the program and its perform the its original number and its reverse number.

Here is the code of the program:-

public class DoWhile{
 
 public static void main(String[] args){
    int n = 12345;
    int t,r = 0;
    System.out.println("The original number : " + n);
 
   do{
      = n % 10;
      r = r * 10 + t;
      n = n / 10;
    }while (n > 0);
    System.out.println("The reverse number : " + r);
  }
}

Download The do - while Example

                         

» View all related tutorials
Related Tags: c com file ide class files stl date time variables static directory io make variable dates sed get ria this

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.