Share on Google+Share on Google+

While Loop Statement in java 7

This tutorial, helps you to understand the concept of while loop in java 7.

While Loop Statement in java 7

This tutorial, helps you to understand the concept of while loop  in java 7.

While Loop Statements :

While loop is most used loop in programming. We put the condition with in the while loop and if condition satisfied then the while block executes otherwise break the loop. You can use any counter to iterate the loop. This type of control structure repeat the task certain number of times. It is more easier to understand in comparison to for loops.

Syntax :


When executing, if the expression result is true then statement inside the loop will get executed and it will continue as long as the expression result is true.

Example :

Here is Simple example of while loop.

package looping;

class WhileLoop {
	public static void main(String[] args) {
		int i = 1;
		System.out.println("While loop example");
		// Using while loop
		while (i <= 10) {
			System.out.println("Hello " + i);
			i++; // incrementing i with 1


Output :

While loop example...
Hello 1
Hello 2
Hello 3
Hello 4
Hello 5
Hello 6
Hello 7
Hello 8
Hello 9
Hello 10



Posted on: December 24, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: While Loop Statement in java 7  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image