Netbeans: How do I break on a NullPointerException?

后端 未结 1 1915
长发绾君心
长发绾君心 2021-02-03 21:19

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

1条回答
  •  感动是毒
    2021-02-03 21:53

    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.

    0 讨论(0)
提交回复
热议问题