From the course: Java for All Platforms: Desktop, Web, and Mobile Development

Unlock the full course today

Join today to access over 23,500 courses taught by industry experts.

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…

Contents