Im having an issue with the command prompt, I have done a helloworld.class and run it, and it outputs hello world obviously, but then i wrote this.
It compiles, and seems to run, but the command prompt shows nothing. Any advice? I tried to change the buffer size on the command prompt much higher but I still get nothing. I even attempted to lower the number of bottles form 99 to 10 like you see above.
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Joined: Oct 02, 2010
I am running BeerSong. Sorry for the miscommunication at the top. I was saying that I had done the helloworld previously. Again I will re-iterate. I wrote the BeerSong tutorial, the code is attached, I recieved a couple error messages when compiling it the first time, fixed the errors, and got it to compile. When I try to run BeerSong via java BeerSong the program or "class" runs, and nothing prints out on the command prompt. I attempted to increase the buffer size to allow more text, that didnt work either. I then attempted to lower the starting int for BeerSong to 10, in an attempt to cut down on the output. Re-compiled it. Attempted to run it and the same, it runs and cursor sits a line below, nothing prints on the command prompt.
The semicolon on this line doesn't belong there, and it's the whole problem:
while (beerNum > 0);
This line could be translated into English as "If beerNum is greater than zero, do nothing, then check beerNum again. If it's greater than zero, do nothing, then check again. And so on, and so on, forever." That lone semicolon is an empty statement -- a valid line of Java code that does nothing, and it's the body of the while loop. Since the variable never changes by doing nothing, nothing ever happens.
What you actually want is for the big blob of code in brackets to be the body of the loop. Take that semicolon out, and it will be!
Thank you both very much. I've been staring at this thing for hours possibly why I couldn't see it. Esentially I was making while a statement. SMASH HEAD ON DESK! Honestly, thank you both for pointing it out.