1 / 6

Debugging : Using the Stack Trace

Debugging : Using the Stack Trace. Initially click on the highest line which refers to a class written by you. The lower lines show how the execution got there, so that might be useful too. DEBUGGING : Inserting System.out.print statements.

nancyaking
Télécharger la présentation

Debugging : Using the Stack Trace

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Debugging : Using the Stack Trace Initially click on the highest line which refers to a class written by you. The lower lines show how the execution got there, so that might be useful too. DEBUGGING IN NETBEANS

  2. DEBUGGING : Inserting System.out.print statements • Simple and effective debugging technique if used intelligently • Use to check whether a block of code is ever executed System.out.println("got here"); • Use to check the value of a variable System.out.println(“number is “+num); • Essential to remove debugging statements from final version of program DEBUGGING IN NETBEANS

  3. USING THE NETBEANS DEBUGGER : 1 Finish Step into Step out Run in Debugger Step over Continue Use the Debug menu or the buttons at the right hand side of the toolbar. You can watch how your program executes and how the variables change as the code is executed. DEBUGGING IN NETBEANS

  4. USING THE NETBEANS DEBUGGER : 2 • A breakpoint is a line where you want execution to stop • Insert breakpoints at or before problem code • click in left margin of source editor and line is highlighted in red, and red square appears in margin • Run the program in the debugger (Debug : start session), program will stop at breakpoint • Variables are declared in windows at left and can be expanded • Ensure that the toggle switch to show private is on DEBUGGING IN NETBEANS

  5. USING THE NETBEANS DEBUGGER : 3 • Stepping through a program • Step Over (F8) to move from one line of a method to the next (see how variables change) • Step Into (F7) to move into one of your own methods (but NOT into java methods) • Step Out to move out of a method to the statement after the method call • Continue to run to the next break point • Finish to stop the debugger DEBUGGING IN NETBEANS

  6. USING THE NETBEANS DEBUGGER : 4 • Local variables are displayed in the Local Variables window • A Watch is a variable or expression whose value is displayed in the Watch window • lets you easily see how its value changes as the code is executed • to set a watch • rightclick on the variable or expression you want to watch • select New Watch from the drop down menu • in the dialog box fill in correctly the variable or expression • Hover mouse over variable in Source Editor to see current value in a tooltip • only works for variables/expressions currently in scope • sometimes doesn’t seem to work even for them ! DEBUGGING IN NETBEANS

More Related