How to Avoid an Infinite Loop
Does your loop never stop?
Give it a condition that eventually becomes false.

Things to check:
- Make sure the condition changes
- Increment your counter
- Update variables used by the condition
- Use
breakwhen appropriate - Avoid accidental
while (true)loops
A loop continues while its condition evaluates to true.
If the condition stays true forever, the loop also runs forever.