From the course: Java's Toughest Bugs

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Endless loop symptoms

Endless loop symptoms - Java Tutorial

From the course: Java's Toughest Bugs

Endless loop symptoms

- [Instructor] The endless loop bug is a well-known issue that can cause your application to freeze. It happens when a section of code repeats indefinitely without reaching an exit condition. It's like you're cycling on an indoor bike. You're moving and you're working, but you never reach a destination. Let's take a look at some code. This is a classic example of an endless loop. We create a variable X, and then create a loop that will print a message while X is greater than zero. Unfortunately, with this code, the program will never reach the out-of-loop print statement. Let's run it. (mouse clicking) In the console, we see the in loop message printed over and over again, without stopping. If your application displays a log repeatedly without any signs of progress, you might have an endless loop on your hands. (no audio) In some cases of this bug, you might not have a print statement in the loop. Let's remove it and…

Contents