Welcome -
Guest!
Login
/
Register Now
|
Search:
Home
Articles
Forum
Interview FAQ
Activities
News
Videos
Poll
Links
People
Groups
Java Articles
Submit Article
Home
»
Articles
»
Java
»
Fundamental
RSS Feeds
do loop or do-while loop
Posted By:
Khadeeja Malik
Category:
Java
Views:
6074
This article explains about do loop or do-while loop in java with examples.
do-while statement provides a form of loop. do loop repeats the statement or statements while the expression is true. It stops when the expression becomes false.
Note that do-while loop is unique because it will always execute the code within the loop at least once, since the expression controlling the loop is tested at the bottom of the loop.
Syntax of do-while loop
do
{
statements;
}while(expression);
Example of do-while loop
Example 1 : Program to print number from 1 to 10 using do-while loop
class DoWhileLoopDemo
{
public static void main(String args[])
{
int i = 1;
System.out.print("Numbers : ");
do
{
System.out.print(i + " ");
i++;
} while(i >= 10)
}
}
Output
Numbers : 1 2 3 4 5 6 7 8 9 10
Share:
Previous Post:
While Loop
Next Post:
Nested Loops (Nested for , Nested While, Nested do-while)
Didn't find what you were looking for? Find more on
do loop or do-while loop
Or get
search suggestion and latest updates
.
Khadeeja Malik
author of do loop or do-while loop is from Karachi,
Pakistan
.
View All Articles
Related Articles and Code:
Program that Displays one or more data on the DOS standard output device
Decision Making and Looping using while statement , do while loop , for statement
Using the POSIX threads library, write a 2-thread program for Linux.Once the thread spawning is done, the first thread (T1) should wait for user input
Program to do sum of elements of an array by Loop Splitting
Find maximum and minimum of an array using Loop Splitting
Program of histogram using loop splitting and locking the each bin with a different lock
Nested Loops (Nested for , Nested While, Nested do-while)
PROGRAM USNG WHILE LOOP FOR THE FIBONANSI SERIES AS SHOWN IN DESCRIPTION
PROGRAM USNG WHILE LOOP FOR THE FIBONANSI SERIES IN TRIANGLE SERIES
Program to show the use of For Loop
Program to show the use of While Loop
Program to show the use of Do-While Loop
Program to show the use of Nested Loops
For Loop Control Statement
While Loop
Program to print Upper Case Letters from A to Z ( Simulation of While Loop )
Program to print Upper Case Letters from A to Z ( Simulation of Do-While Loop )
Program that prints the first 10 integers(using for loop)
Program that prints odd numbers form 0 to 50 (Using for Loop)
Program that reads a number ,coumputes and displays its factorial ( using for loop )
Other Interesting Articles in Java:
Program to show an example of Copying i.e. Clonning Objects
Program to show an example of modifying String objects
Public Variable
An applet program to give demo of getDocumentBase() and getCodeBase() methods
Program which will read a string and rewrite it in the alphabetical order
An applet program to display sum of two number of textField
Method Overriding
RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user
Program to show an example of using a Static Nested Class outside the Top-Level Class
Program to show the use of Do-While Loop
Abstract method
Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception
Program to read command line arguments
Program to show an example of using a Non-Static Nested Class
Class modifiers in java
Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server
Program to show an example of using multiple classes in a program
An applet program to perform selection sort
CORBA PROGRAM TO GET THE HTML CODE FROM ANY URL
Program to show the use of Comparison operator (==) for comparing Strings
Please enter your Comment
*
*
Comment should be atleast 30 Characters.
Please put code inside [Code] your code [/Code].
Please login to post comment
No Comment Found, Be the First to post comment!
Java
View All
Applet programs
Arrays
Comparison Operator
Corba
Data file structure
File Handling
Fundamental
Homework Help
Interview FAQ
Networking Technology
Operators
Remote Method Invocati...
Socket Programming
Assembly Language
Artificial Intelligence
C Programming
C++ Programming
Visual C++
OOAD
Cobol
SQL Server
Asp.net MVC
Rest and WCF Services
Entity Framework
Knockout.Js
Unix / Linux / Ubuntu
Networking
OOPs Concept
HTML
Dos
SQL
System Analysis & Design
Gadgets
Internet
CSS
Javascript
.Net Framework
Asp.net
C#
VB.Net
Python
Perl
Oracle
Software Engineering
RDBMS Terms
AJAX Framework
Design Pattern
UML
WPF
WCF
SEO
PowerShell
Visual Studio
WWF
BizTalk Server
Azure
General
Testing
Online Certifications
PHP
My SQL
LinQ
Project Management
Silverlight
XML
MS Office
Windows OS
DHTML
Sharepoint