Skip to content

Instantly share code, notes, and snippets.

@durgaswaroop
Last active January 2, 2017 15:30
Show Gist options
  • Save durgaswaroop/acb6d688fbbfeda3c8a68267ce680c05 to your computer and use it in GitHub Desktop.
Save durgaswaroop/acb6d688fbbfeda3c8a68267ce680c05 to your computer and use it in GitHub Desktop.
Intellij Debugging

From the stack overflow question here, If we have a code like this,

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
    }
}

And we are at the line f(x) in the method g(..).

  • Step Into - Goes in to the definition of funtion f(..) and goes to the println statement in f(..)
  • Step Over - Goes to f(1) which is the next line stepping over the function call
  • Step Out - Runs enough code to get you one level up from the current level. In this case it will go to either g(2) or g(3) depending on what called that f(..)

In a more generic way

  • Step Over - When you do step over, you always go to the next line in the program irrespective of whether the current line is a statment or a call to a function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment