I saw a nice explanation online. And I thought I should share this.
Consider the following code with your current instruction pointer (the line that will be executed next) at the
f(x);
line in g()
:public class testprog {
static void f (int x) {
System.out.println ("num is " + (x+0)); // <- step into
}
static void g (int x) {
-> f(x); // <----------------------------------- current location
f(1); // <----------------------------------- step over
}
public static void main (String args[]) {
g(2);
g(3); // <----------------------------------- step out of
}
}
If you were to step into at that point, you will move to the
println()
line in f()
, stepping into the function call.
If you were to step over at that point, you will move to the
f(1);
line in g()
, stepping over the function call.
Another useful feature of debuggers is the step out of or step return. In that case, a step return will basically run you through the current function until you go back up one level. In other words, it will step through
f(x)
and f(1)
, then back out to the calling function to end up at g(3);
in main()
.
Eclipse (at least Europa, which is the only one I have handy at the moment) uses F5 for
step into
, F6 for step over
and F7 for step return
.
read more at : http://stackoverflow.com/questions/3580715/what-is-the-difference-between-step-into-and-step-over-in-the-eclipse-debugger
No comments:
Post a Comment