开发者

How can I debug my code?

开发者 https://www.devze.com 2023-01-16 14:24 出处:网络
I asked about some non-working code I had at Code works extremely slowly and does not print output. As you can see in the answer to that question, deks 开发者_如何学JAVAdebugged my code and also prov

I asked about some non-working code I had at Code works extremely slowly and does not print output.

As you can see in the answer to that question, deks 开发者_如何学JAVAdebugged my code and also provided the output of the fib() function. How could I do that by myself? I really know very little about debugging.


To debug, get yourself and IDE like NetBeans or Eclipse. Then instead of clicking run, click on line number then click debug. When the execution gets to this point, it stops, and you can examine the variables that are currently visible. To make sure they have values they should have. For example, if n should be between 1 and 10, and it is 100, then you know something is wrong. Fine where you set n, and add more breakpoints. These are the points were the execution will stop. You can also click step over, to execute the next line, then stop, or step into, which will execute the next line, except it will step into any functions that you used.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号