Hello again forums, i've been around here for a few days now
been re-writing small programs daily trying to get down the basics
of this while learning the fundamentals of Java. Anyways I have
a quick question. In the code I have below
It lets me input text and stores it in the name var for me.
It only stores the first Word I type though. Exp,
"Hello, what is your'e name?" Kara Kodet
"Ok, so you're name is Kara."
Could someone help me with what would I use if
I wanted it to print out all the text a user would type
so therefor, it would print out
"Ok, so you're name is Kara Kodet."
Edit: Oh, & the new beta view, is Super Sexy had to mention! (: Good Job
Can't wait to see the final release.
Bp Parker wrote:It lets me input text and stores it in the name var for me.
It only stores the first Word I type though.
Because next() gets the next token; and by default Scanner delimits its tokens with whitespace.
As Campbell said, you can use nextLine(), which will return everything you type up to the point you hit the 'enter' key.
Personally, it's the only method I use for keyboard input, because it's very straightforward and it always leaves the Scanner in a state to accept another line - but many people (including Campbell ) disagree with me on this.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here