Do-While Statements
Submitted by GeePee on Friday, June 12, 2015 - 23:09.
Introduction:
This page will teach you how to use the Do-While statements in Java.
Important!
It is fairly important you understand the While Statement before reading this tutorial page. It can be found on the main Java Tutorial Thread page.
What is a Do-While Statement?
A Do-While Statement is very similar to a While Statement, with one exception. The conditions that require to be true for the code to re-execute are checked at the bottom of the loop which therefore means the while script is executed at least once (before the first check).
Examples:
The above code executes the output once while the boolean "thisTrue" is false, it then changes to true and outputs continuously. The output given was:
Executing...
{Infinite Loop Starts Here}
Executing...
Executing...
Executing...
Executing...
{Continues...}
Finished!Add new comment
- 96 views