Changing the following the while loop to the for loop int co

Changing the following the while loop to the for loop:

int counter=0;

while(counter<10)

{

System.out.println(\"Test2 is very easy!\");

counter++;

}

Question 16 options:

Solution

Here is the answer for changing given while loop to for loop:

for (int counter=0; counter<10;counter++){

System.out.println(\"Test2 is very easy!\");

}

Syntax :

Following is the syntax of enhanced for loop

Compleate JAVA code :

public class MyClass {
    public static void main(String args[]) {
        for (int counter=0; counter<10;counter++){

System.out.println(\"Test2 is very easy!\");

}
    }
}

Changing the following the while loop to the for loop: int counter=0; while(counter<10) { System.out.println(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site