View Single Post
Old Jul 6th, 2007, 2:20 AM   #3
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,009
Rep Power: 5 lectricpharaoh will become famous soon enough
I've run into a similar problem. It seems that the Java libraries (or possibly the VM) have a bug whereby the output stream and input stream are tied together. If you put a newline at the end of the prompts, or use println() instead of print(), it should work as you intend. I've tried flushing the output stream, to no avail. In my case, the bug manifested by the input not working unless it was printing a newline character; the symptom was an endless loop. Now, why changing what the output should affect the input is beyond me; hence my thinking that it's a bug. It also makes it impossible to have a proper prompt where the user enters stuff on the same line as the prompt.

[edit] I just tried your code; it works fine for me. Go figure. [/edit]
Quote:
Originally Posted by 357mag
Well I guess if you change it to say println instead of just print then it works. Although I don't understand why.
Hence it being a bug.
Quote:
Originally Posted by 357mag
I have another question though. Every time I run the program, the previous first integer value is still sitting in the input box. Is there any way to make it so when you start the program anew that the input box is clear?
The first time you said 'input box', I dismissed it, but now you've said it again. I don't know what you're referring to. Are you running this through some IDE, or something? If so, have you tried running it from the command line?
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick

Last edited by lectricpharaoh; Jul 6th, 2007 at 2:37 AM.
lectricpharaoh is offline   Reply With Quote