Rewrite using for loop : while(true) System.out.print(“*”)
Answers
Answered by
21
for(int x=1;x<=5;x--)
{
System.out.print("*");
}
Answered by
29
The given while loop is an infinite loop i.e. it will run infinitely many times and will never cease because no condition is given to the while statement. The while statement will always be true irrespective of any condition and will keep on printing the ‘*’ character.
The given loop can be rewritten using for loop as :-
for(i=1;i>0;i++)
{
System.out.print("*");
}
Similar questions