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:
2775
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 that reads a number ,coumputes and displays its factorial ( using for loop )
Program that prints odd numbers form 0 to 50 (Using for Loop)
Program that prints the first 10 integers(using for loop)
Program to print Upper Case Letters from A to Z ( Simulation of Do-While Loop )
Program to print Upper Case Letters from A to Z ( Simulation of While Loop )
Program that prints first 20 integers in reverse order (using while loop )
Program that prints first 20 integers (using while loop)
Program that reads a number ,coumputes and displays its factorial using do-while loop
Program of finding Maximum and minimum of an array using Loop Splitting
Program to do sum of elements of an array by Loop Splitting
Program of histogram using loop splitting and locking the each bin with a different lock
Program to show the use of While Loop
Program to show the use of For Loop
Program to show the use of Do-While Loop
Program to show the use of Nested Loops
For Loop Control Statement
Nested Loops (Nested for , Nested While, Nested do-while)
PROGRAM USNG WHILE LOOP FOR THE FIBONANSI SERIES AS SHOWN IN DESCRIPTION
Other Interesting Articles in Java:
Method Modifiers
An applet program to perform merge sort
Public Constructor
Program to find a factorial of a given number
Nested Loops (Nested for , Nested While, Nested do-while)
Program of concatenating and Buffering files
Program to declare, initialize and print an array of characters
An applet program to take user input and display
Classes and Objects
Protected Constructor
Arithmetic Operators
Program to show an example of creating Character Arrays from String objects
Program to show the comparing of Strings for equality
Program to show an example of searching Strings for characters
Public Class
Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server
Instance methods and variables
Simple Applet which will show life cycle of an Applet
Program to display reverse $ tree
Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong
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