Java while loops statement allows to repeatedly run the same block of code, until a condition is met.
Syntax:
Example:
public class Sample {
public static void main(String args[]) {
/* local variable Initialization */
int n = 1, times = 5;
/* while loops execution */
while (n <= times) {
System.out.println("Java while loops:" + n);
n++;
}
}
}
Program Output:
No comments:
Post a Comment