do while loop java example
Example 1: java do while
do {
} while ();
Example 2: what is a do while loop in java
do {
} while (someBooleanCondition);
Example 3: do while loop java
do while loop java executes the statements and then evaluates the
expression/condition of loop’s body until given condition is true.
Here’s do while loop syntax in java.
do{
statement(s);
}while(expression/condition);
Example 4: while loop in java
public class ArrayWhileLoop
{
public static void main(String[] args)
{
int[] arrNumbers = {2, 4, 6, 8, 10, 12};
int a = 0;
System.out.println("Printing even numbers: ");
while(a < 6)
{
System.out.println(arrNumbers[a]);
a++;
}
}
}