

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to debugging techniques for java programs in the cs110: introduction to computer science course. It covers the difference between compiler and run-time errors, and introduces debugging tools like eclipse and their functionalities such as breakpoints, stepping over and in, and resuming execution. The document also includes an instructor sample of debugging a mastermind program.
Typology: Study Guides, Projects, Research
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CS 110: Introduction to Computer Science Spring 2008
With a little of ‘this’ and object equality Debugging—finding run-time errors in your program Compiler/syntax errors—in Java, these are the ones javac tells you about. maddening for beginning programmers, but really like a helpful grandmother Run-time errors—when you run a program (java Program) and things don’t work as they should. These are the ones that can keep you up all night. How do you debug programs now? Debugging tools, like the one in Eclipse, can help very, very much! Debuggers let you run your program to specific points, look at variable values during execution, and step through the program a statement at a time.
Breakpoints —you can specify that the debugger stop execution at any point in the program. Step Over -- When execution is stopped at a statement, you can have the debugger execute one statement at a time. If it’s a method call, the debugger will execute the entire method and return execution to the statement after the call. Step in —Execute one statement, but if it’s a method call stop execution at the top of that method. Step return —return execution from the method your in to the caller. Resume —Tell the debugger to run the program until the next breakpoint.
CS 110: Introduction to Computer Science Spring 2008
Create a directory called mm, save the files above into it. Then open Eclipse and create a new project, choosing to ‘create project from existing source.’
Start in the main Step over statements until you find the method call causing the problem Then step into that method (or set a breakpoint in it) and step through it. You may have to dig further into methods called by that method.
You are in control. You write the program. The debugger allows you to see what’s happening at all points in the program. No more mystery! No more guessing! (Well, maybe some)