toreforex.blogg.se

Bluej main method
Bluej main method











#Bluej main method code#

Build, Run & Share Java code online using online-java's IDE for free. That would avoid all this confusion.Online Java is a web-based tool powered by ACE code editor. 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

bluej main method

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.

bluej main method

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.











Bluej main method