1. Set a breakpoint where you think something is wrong.
Right-click before the line of code. Note that it is the right-click, and then select Toggle Breakpoint.
#2. Click Debug. If it is a web program, you need to start the Tomcat or Apache server in Debug mode.
This is very important. The standard Start mode cannot enter the preset breakpoint, and the purpose of debugging cannot be achieved.
#3. Run the program. When the program reaches the breakpoint you just set, it will stop, and the background color of that line of code will be highlighted
4. Enter the debugging interface to view the debugging information
5. Finally, you can modify the program based on the debugging information
Debugging completed!
Recommended tutorial:java introductory tutorial
The above is the detailed content of How to debug a program in java. For more information, please follow other related articles on the PHP Chinese website!