JavaUser JavaUser - 2 years ago 189
Java Question

What is the difference between Step Into and Step Over in the Eclipse debugger?

I want to debug the whole flow of a Java program. What is the difference between F5 (step into) and F6 (step over) in eclipse?

Answer Source

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(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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download