课程: Java for All Platforms: Desktop, Web, and Mobile Development

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Debugging code

Debugging code

- [Instructor] In a perfect world, there would never be bugs in any code. But even the best Java developers sometimes make mistakes and have to debug problems. For that reason, knowing how to debug your code is an invaluable skill. Let's take a look at our test right here. So I'm going to run that, and watch what happens. As the test runs, it fails. We expected 1, and the actual value was 0. So how do we resolve this problem? Now, we only have one class in our code that has any logic in it, but what if we had hundreds or thousands of classes in our code, and we didn't necessarily know exactly where the problem was? Using the debugger effectively can help you quickly narrow down the problem and find the solution. Let's take a look at how that works. What I'm going to do is put a break point on line 10 by clicking to the right of line 10. So that puts this red dot right here. I can see the assertion that failed…

内容