AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Java visualizer blurry12/28/2023 An animated gif showing off this process is available at this link. This will allow you to show both the debugger and the console at the same time. Click and drag the “Console” window to the far right of the bottom panel. At the top left of the information window in the bottom panel, you should see tabs labeled “Debugger” and “Console” (and “Java Visualizer”). If the text console (that says things like “round(10/2)”) does not appear when you click the debug button, you may need to perform one additional step before proceeding. An animated gif showing off the steps in this paragraph is available at this link. If you’d prefer to avoid right-clicking to run your program again, you can click the bug icon in the top right of the screen instead. If we run the program in debug mode again it’ll stop at that line. You should see a red dot appear that vaguely resembles a stop sign, which means we have now set a breakpoint. To do so, scroll to the line that says int t3 = 3, then left click just to the right of the line number. Let’s fix that by “setting a breakpoint”. You’ll see that the program simply runs again, with no apparent difference! That’s because we haven’t give the debugger anything interesting to do. If theĭebug option doesn’t appear, it’s because you didn’t properly import your lab2 In the left-hand Project view, right click (or two finger click) on theĭebugExercise1 file and this time select the Debug option rather than the Run option. Our first exercise introduces us to two of our core tools, the breakpoint and the With each new piece of evidence, you will refine your hypotheses, until finally, you cannot help but stumble right into the bug. Generally speaking, you should formulate hypotheses about how segments of your code should behave, and then use the debugger to resolve whether those hypotheses are true. We encourage you to do what one might call “scientific debugging”, that is, debugging by using something quite similar to the scientific method! While they are powerful, debuggers have to be used properly to gain any advantage. The IntelliJ debugger allows you to pause the code in the middle of execution, step the code line by line, and even visualize the organization of complex data structures like linked lists. Often (but not always) it takes less time and mental effort to find a bug if you use a debugger. And they provide their results in a format that can be hard to read, since it’s just a big blob of text in the execution window. They require you to explicitly state what you want to know (since you have to say precisely what you want to print). While print statements can be very useful for debugging, they have a few disadvantages: They require you to modify your code (to add print statements). Many of you have had lots of experience with using print statements to probe what a program is thinking as it runs. Somewhere in our code there is a bug, but don’t go carefully reading the code for it! While you might be able to spot this particular bug, often bugs are nearly impossible to see without actually trying to run the code and probe what’s going on as it executes. If you’re not sure how to run DebugExercise1, right click on it in the list of files and click the Run DebugExercise1.main button as shown below: You should see three statements printed to the console, one of which should strike you as incorrect. Open up this file in IntelliJ and click the run button. We’ll start by running the main method in DebugExercise1. However, this time, you should import from your lab2 directory instead of your lab2setup directory.Īfter importing, your IntelliJ should look something like the following: Repeat the project setup process from lab 2 setup. Your job for this assignment is to run through the debugging exercises and toĬreate methods for IntList.java. In this lab, you will learn about basic IntelliJ features, destructive vs. Run git pull skeleton master in your repo.Java files have a red circle, with a J inside the circle, next to the file icon.Things like String or String.equals() are red!.Further Guidance (for those who want it).Lab 2: Unit Testing with JUnit and IntLists
0 Comments
Read More
Leave a Reply. |