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

Java – do loop

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

The difference between do-while and while is that do-while evaluates its expression at the bottom of the loop instead of the top. Therefore, the statements within the do block are always executed at least once.


int num = 0;
do {
System.out.println("Line " + (num++));
} while (num < 5);

The loop will continue to increment by one on every loop untill it reaches 5.

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