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:
6172
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 that will count the number of lines in each file that is specified on the command line
Program to copy the elements of an array into another array in reverse order and print them
Continue Statement
Inheritance or Superclass - Subclass Concept
Program to show the use of Logical AND Operator (&) in If Statements
Bitwise Operators
Program to declare, initialize and print a StringBuffer object
An applet program of showing new document using showDocument(URL) method
General Form of a Class
CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side
Short Wrapper Class
Variables Inheritance and use of Super keyword to access superclass variable
Private Method
Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file
Program to show an example of using multiple classes in a program
Program to print a string on Standard Output Device
Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class
Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.
Float Wrapper Class
An applet program to find maximum of three numbers using textField
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