• Home
  • About
  • Work Portfolio
Blue Orange Green Pink Purple

Java – while loop

Posted in Java. on Saturday, January 30th, 2010 by Daniel Noormohamed
Jan 30

The while statement is used to repeat a block of statements while some condition is true. The condition must become false somewhere in the loop, otherwise it will never terminate.


int i = 1;
while (i <= 5) {
System.out.println(i + " squared is " + (i * i));
i++;
}

The output result for the above could would be

1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25

Leave a Reply

You must be logged in to post a comment.

Noormohamed

  • About
    About me. Edit this in the options panel.
  • Photo Stream
  • Categories
    • CSS
    • Donate
    • Hosting
    • Java
    • jQuery
    • PL/SQL
    • VMWare
    • WordPress Plugin
  • Recent Articles
    • PL/SQL Basic Insert (no return)
    • VMWare Player on a VMWare ESX Guest
    • Java – do loop
    • Java – foreach equivalent
    • Java – while loop
    • Java – for loop
  • Archives
    • February 2010
    • January 2010
    • April 1999
  • Search






  • Home
  • About
  • Work Portfolio

© Copyright Noormohamed. All rights reserved.
Designed by FTL Wordpress Themes brought to you by Smashing Magazine

Back to Top