A debugger allows us to:
Debuggers are very useful tools to detect the causes of errors in programs.
Example 1:
int a, b, x; a = 5; b = Integer.parseInt(kb.readLine()); // reading of b ... // statements that do not change b x = a/b;
By means of a debugger we can verify the value of the variable b before executing the statement that generates the error.
Example 2:
String s, t; s = null; ... t = s.concat("a");
The assignment statement for t generates an exception of type NullPointerException. Such an error depends on the fact that, when the assignment statement is executed, the value of s is null. To check this error, we can use a debugger and observe the value of the variable s before executing the statement that generates the error.