E.3 The print and set Commands

In the preceding section, you learned how to use the debugger’s print command to examine the value of a variable during program execution. In this section, you’ll learn how to use the print command to examine the value of more complex expressions. You’ll also learn the set command, which allows the programmer to assign new values to variables.

For this section, we assume that you’ve followed Step 1 and Step 2 in Section E.2 to open the Command Prompt window, change to the directory containing the Appendix E examples (e.g., C:\examples\debugger) and compile the AccountTest application (and class Account) for debugging.

1. Starting debugging. In the Command Prompt, type jdb to start the Java debugger.

2. Inserting ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.