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:
6260
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:
File handling program to count number of characters in a file
Program to extract a portion of a character string and print the extracted string
An applet program to add two number's where data is entered in TextField
Program to show the use of operator (>>) Shift Right, propagating the sign bit from the left
Program to show an example of using a Static Nested Class outside the Top-Level Class
Program of binary search tree
An applet program to display barchart of given data
Variables and Assignments
Inheritance or Superclass - Subclass Concept
Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained
An applet program that creates string dynamically and displays it
Program to show an example of searching Strings for characters
Program to show the use of Logical OR Operator (|) in If Statements
Simple Applet which will show life cycle of an Applet
Even no or Prime no?????
Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01
Continue Statement
Constructor inheritance and use of Super keyword to access superclass constructor
Program to show an example of Copying i.e. Clonning Objects
Program to show an example of using user-defined package in a program
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