问题
When debugging a java program in netbeans, I want the debugger to stop on the line that causes a NullPointerException so I can examine the variables there. I believe I have to use a condition on the breakpoint set at that line, but what is the syntax of the condition?
thanks for the help
回答1:
Go to debug > New Breakpoint (alternatively CTRL+SHIFT+F8). Change the breakpoint type to Exception in the top right hand drop down menu. Type java.lang.NullPointerException
in the Exception class field. Choose whether to break on caught, uncaught or both.
Debug your code and watch the glorious auto breakpoint when the Exception is thrown.
来源:https://stackoverflow.com/questions/2669808/netbeans-how-do-i-break-on-a-nullpointerexception