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.
Debugging steps - Java Tutorial
From the course: Java's Toughest Bugs
Debugging steps
- [Instructor] Once the endless loop has been found, we can begin debugging to find the root cause. The first step is to replicate the issue and replicate its symptoms, which is what we've done with the last video. Now that we've located where the loop is, we can use the debugger to monitor the loop's iteration, and analyze its behavior during runtime. Let's add a break point within the loop and run the program again. We'll run it in debug mode. Here the program stops right before it executes the first in loop print statement. Let's step over this line and check the value of x. x still has the value of five because we have not modified it. Let's step over again and again and again. The value of x remains five. This means we need to change the code in the for loop so that x is decremented and the loop can be terminated. Let's take a look at another endless loop example. This endless loop scenario is very similar. The…