简体   繁体   中英

How To Run Eclipse Debugger Mode to See Order of Operations?

In a previous question I had asked about recursion one of the responses recommended that I use debugger mode to see the order of operations. I had a few more order of operations questions, but figured I should use the debugger to run it instead of asking silly questions each time.

I ran the application in "Debug As" -> "Java Application" in Eclipse, and it just runs the program in a normal console giving me the same result as if I were to run it.

This is the program in question(Just what I am using to test Debug, I don't have questions regarding this actual app):

public class main {
public static void main(String [] args){
System.out.println(fact(5));

}

public void fact()
{
fact(5);
}

public static int fact(int n)
{
if(n == 1){
    return 1;
}
return n * (fact(n-1) + 5);
}
}

In Debug mode it just provided me with "1145", which is the same thing that the normal "Run" mode provides me.

I wanted to see the actual step by step instructions that are being fed into the JVM, which is what I gathered that Debug is supposed to do.

I read online instructions on how to Debug applications, and that tutorial had different options in Eclipse then mine, such as "toggle breakpoint", which I do not have in the most recent version of Eclipse.

Can someone please point me to a direction as to how to get Eclipse to show me step-by-step operations.

您需要在代码中添加调试点。查看如何调试

In Eclipse you double-click in the left margin beside a line and it will set a breakpoint at that line and mark it.

When you run in debug mode, it will stop when it gets to a line with a breakpoint and you can look at the stack and variable values and what-not. A whole new perspective will try to pop up when it hits that breakpoint that has lots of windows with interesting info.

If you double-click in the left margin, you can set a breakpoint. It will appear as a blue dot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM