The suite also includes an instructional PDF that includes everything a beginner might need to know about Java and the BlueJ system. The user interface for this software is specifically designed for ease of use, which makes it the optimal method for learning Java if you have no experience with the coding language. That includes text and graphic editing, interactive object development, a debugger, compiler, integrated editor, and virtual machine. That would avoid all this confusion.BlueJ is an introductory piece of software designed to help those starting off with Java learn the basics of the programming language in an environment that won't overwhelm or discourage novice users.Įverything you might expect to be included in a full-featured Java environment such as this one has been included. In general, you should always print a prompt immediately before getting any input. ![]() You could instead kill BlueJ and restart it, but that's pretty darn ugly. To actually read the input you've placed in the Terminal Window.) Alternatively, Type in the Terminal Window, you may have to click on Terminate to get the program Yuck!!! (If you've already hit the Halt button when you No matter what, you still have to go to the Terminal Window andĮnter a value there. You can alternately click on Halt and Terminate until you are blue Nice if BlueJ displayed an arrow at the readInt line.Anyhow, at least you know that the program is waiting for input, and not infinite looping.Įven worse than that, clicking on Terminate does NOT actuallyĬause the program to terminate!!! Doing so only "reactivates" the Waiting for input! This is a pity, because it sure would be To display an arrow in the source code window indicating where the program is Why? Because clicking on Halt does NOT cause BlueJ Unfortunately, if there were more than two such instructions, you couldn't tell You won't recognize the names of any of these, because they are indirectly invoked when you call nextInt(). The Call Sequence shows what methods or functions are currently being evaluated by your program. You will see something that looks like this: I've just outlined to determine where the loop is in your code.ĭebugger, select main and click on the Halt button. Consequently, you might-mistakenly-consider using the technique You might be confused and think that there wasĪn infinite loop. In the Terminal Window that the program is waiting for input. Because this method doesn't print anything, there is no indication I mean, try running the Infinite.input method that is defined in To be infinite looping, but is actually merely waiting for input. Unfortunately, this same process will not work if your program merely appears Using the debugger you can also examine the values of variables if you want.Įventually, you will want to terminate your program, so click on the Terminate button. This will execute the next line of your program, and then stop. ![]() Well be stopped at a different place in the program!)Īt this point, you can continue to click on the "Step" button in the debugger. Showing the next line of code in your program that will be executed. Next, Click on the "Step Into" button in the debugger,Īnd your editor should pop up, with an arrow and a yellow highlight box Okay, now click on the "main" entry, as indicated above, then click on the "Halt" button as indicated below, and the debugger window will change to something like:Īt this point the candy cane should no longer be spinning (but will still be red). Take a screen shot of this and print it with your name. ![]() This will bring up a window that looks like this. Once the candy cane is spinning again, select the project window, then use the View menu to select "Show Debugger". To see how this works, start the infinite loop again. You can find out exactly where you are by using BlueJ's debugger. This is good to a point, but doesn't let you know where you were stuck in an infinite loop (there may be several loops in your program, for example). Selecting the menu item will halt the program. That'sīecause the CPU is wasting a lot of time executing the infinite loop.) To suspend an infinitely looping program, right-click on the candy-cane. (By the way, your computer might be acting a bit sluggish right now. The candy-cane should just loop and loop. First, let me talk about the situation where your program is Is occluded behind another window, you might not be aware that the program isĪwaiting input. ![]() Waiting for input ellicits the same behavior. Pole") in the Project window just spins and spins. Programs are easy to spot in BlueJ: the "candy-cane" (or, "barbershop What to Do if Your Program Infinite Loops What to Do if Your Program Infinite LoopsĪ common error in programs is loops that never terminate.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |