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:
6053
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 the use of Logical OR Operator (|) in If Statements
Variable modifiers in java
Program to show the use of Bitwise Operator (~) Complement
Boolean Operators
IF-Else Control Statement
Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained
Variables Inheritance and use of Super keyword to access superclass variable
Program to read input from the Standard Input Device
Program that reads and writes random access file
Corba program of reverse string
Program of date server and client
Program to show an example of using a Static Nested Class
this keyword in java
Program that will read real number from the keyboard and print the following output in one line: small Integer not less The Given Number Largest Int
File Handling- JAVA
Program to generate SQUARE ROOT table
Program to read the ballots and count the votes cast for each candidate using an array variable count
Program to show an example of creating Character Arrays from String objects
Abstract class
Increment and Decrement Operators
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