Dan JMR
Dan JMR
Ernest Friedman-Hill wrote:Hi Dan,
When you type in your first character, it won't show up until you press "Enter". But that Enter is an actual character, and it will still be sitting in the input buffer, waiting to be read. Your second "read()" is going to get that "Enter" character (actually a newline, "\n".) If you add an extra "System.in.read()" after the first one, but before the second one, your program will work as you expect, because that etra read() will consume the newline.
Archana Honnavalli wrote:
Please tell me where am i missing code.
Campbell Ritchie wrote:Please tell us more than "doesn't work". What are you doing and what is happening? Are you pushing the enter key?
Campbell Ritchie wrote:You are in fact printing what you entered. Most probably a newline character (0x0a) but you might have a return character ('\r' = 0x0d) on Windows/DOS or an older Mac, as Ernest has already told you. You cannot see the newline, only that your cursor moves to the next line. Add System.out.println("***"); after that, then see where the *** appears.
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|