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:
6199
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 sort the contents of an array using Bubble Sort
Program to check the start and end of a String
Program to show the use of Increment and Decrement Operators
Program to show the comparing of Strings for equality
Switch Statement
Dialog Boxes
Write a class whose objects holds a current value and have a method to add that value, printing the new value
Variables Inheritance and use of Super keyword to access superclass variable
Adding Constructors in a Class
Increment and Decrement Operators
Program to reverse the number eg given no : - 12345, output want :- 54321
Program to search an element in an array using Linear Search
Program to show the use of operator (>>>) Shift Right, filling with zeros from the left
Constructor Modifiers
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
Program to evaluate following investment equation V=P(1+R)^N
Program to show an example of searching Strings for characters
RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct
Even number ,Prime no. ,Factorial of a number
Assignment Operators and Shortcut Assignment 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