Can a while loop run indefinitely?

QuestionsQuestions8 SkillsProPython Control StructuresOct, 03 2025
0108

Yes, a while loop can run indefinitely if its condition always evaluates to true. This is often referred to as an infinite loop. For example:

while (true) {
    System.out.println("This will run forever!");
}

In this case, since the condition is always true, the loop will continue to execute indefinitely until it is interrupted or terminated by an external factor.

0 Comments

no data
Be the first to share your comment!