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
While Loop
Posted By:
Jiro Yoshida
Category:
Java
Views:
2924
This article explains about while loop in java with examples.
While statement provides form of loop. While loop can contain statement or block of statements.
Syntax of While Loop
while(expression) statement;
expression
is any expression. Loop will get executed till the expression returns true. Value of the expression is checked at the top of the loop.
Examples of While Loop
Example 1 : Program that prints 1 to 10
class WhileLoopDemo
{
public static void main(String args[])
{
int i = 1;
System.out.print("Numbers : ");
while(i >= 10)
{
System.out.print(i + " ");
i++;
}
}
}
Output
Numbers : 1 2 3 4 5 6 7 8 9 10
Share:
Previous Post:
Nested IF and IF-ELSE-IF Ladder
Next Post:
do loop or do-while loop
Didn't find what you were looking for? Find more on
While Loop
Or get
search suggestion and latest updates
.
Jiro Yoshida
author of While Loop is from Kyoto,
Japan
.
View All Articles
Related Articles and Code:
do loop or do-while loop
Decision Making and Looping using while statement , do while loop , for statement
PROGRAM TO COMPARE TWO STRINGS USING LOOP SPLITTING
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 FIND CORRELATION BETWEEN TWO ARRAYS USING BARRIER AND LOOP-SPLITTING
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
Program to display numbers using for loop
Program to display numbers using do while loop
Program to display array values using for loop
Program to display array values and address of an array using function and for loop
Program for investment problem using while loop
Program to compute x to the power n using while loop
Program to print 'Power of 2' table using for loop
Illustration of nested for loops
EXAMPLE OF exit WITH goto STATEMENT in a FOR loop
APPENDING ITEMS TO AN EXISTING FILE USING DO WHILE LOOP
Nested Loops (Nested for , Nested While, Nested do-while)
Other Interesting Articles in Java:
Program to show the use of Bitwise Operator (^) XOR (Exclusive OR)
Program to show the use of some Character Methods
Program to show an example of using a Non-Static Nested Class
Program that enabled applet that takes name of the user. Server returns back the number in uppercase clubbed with “HELLO” and display it on applet
Program to show an example of overloading constructors in a class to initialize its data members
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
RMI servlet program to display message
Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side
Corba program of reverse string
Program which will read a string and rewrite it in the alphabetical order
Float Wrapper Class
An application that combines several classes and interface
Program to extract a portion of a character string and print the extracted string
Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()
Corba program of date operations
Program to sort the contents of an array using Bubble Sort
Program to show the use of If Statement
Backslash Codes
Bytecodes and Java virtual Machine
Program to read the price of an item in decimal form (like 75.95) and print the output in paise (like 7595 paise).
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