Computer Applications
Identify all the errors in the following statements.
for (int i = 5; i > 0; i++)
{
System.out.println("Java is fun!");
}
Java Iterative Stmts
3 Likes
Answer
The test expression i > 0 will always remain true and hence, the for loop will become an infinite loop and keep on iterating.
Answered By
2 Likes
Related Questions
What are loop control structures? What are the essential segments of a loop control structure?
How are these statements different from each other?
i. breakii. continue
iii. System.exit(0)
iv. return
Identify all the errors in the following statements.
while (x < 1 && x > 50) { a = b; }Identify all the errors in the following repetitive statements.
while (x == y) { xx = yy; x = y; }