While debugging using print statements is usually not the best technique for finding bugs, it may be useful in a context with limited interactivity or language support. Systems currently in use often support logging status data to a file, so as to provide at least some information about what went wrong if a problem occurs. Likewise, if software support for more sophisticated approaches such as interactive debuggers is not available, logging status output to a console or file may be useful. If debugging using print statements is done, many programmers like to be able to control the output without having to modify each print statement. Using an Interactive Debugger Good development environments provide a tool known as an interactive debugger, or more simply, a debugger.
Debuggers allow examination of the status of a program that is currently executing.
The Java tools we're the using, known collectively as the Java Development Kit, include a debugger called jdb . It allows us to do many useful things, such as examine variable values, see which methods are currently executing and who invoked them, and set breakpoints to make the program stop at various points. Be warned that jdb is sometimes buggy. However, the same concepts covered here will apply to using other debuggers as well. You can set several different breakpoints.