Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Why do you think the Java language provides three different types of loops if al

ID: 3850179 • Letter: W

Question

Why do you think the Java language provides three different types of loops if all loops can be written using the while statement? Why do you think the Java language provides three different types of loops if all loops can be written using the while statement? Why do you think the Java language provides three different types of loops if all loops can be written using the while statement? Why do you think the Java language provides three different types of loops if all loops can be written using the while statement?

Explanation / Answer

1. while loop

while(condition)

{

// statements

}

eg

int i = 1;

while(i<10)

{

System.out.println(i);

i++;

}

Output:

1 2 3 4 5 6 7 8 9

2. do while loop --- execute at least once

do

{

//statements

}while(condition);

eg.

int i = 1;

do

{

System.out.println(i);

i++;

}while(i<10);

Output:

1 2 3 4 5 6 7 8 9

3. Infinite loop

while(true)

{

//statements

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote