Java do while loops is very similar to the java while loops, but it always executes the code block at least once and further more as long as the condition remains true.
Syntax:
Example:
public class Sample {
public static void main(String args[]) {
/* local variable Initialization */
int n = 1, times = 0;
/* do-while loops execution */
do {
System.out.println("Java do while loops:" + n);
n++;
} while (n <= times);
}
}
Program Output:
No comments:
Post a Comment