Results 1 to 4 of 4
Thread: Scanner.next() problems!
- 08-11-2010, 01:30 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 32
- Rep Power
- 0
Scanner.next() problems!
I am writing a code that requires multi-word input. Here's the code I used:
When the user inputs multiple words, however, it gets all funny:Java Code:while (true) { out.print("> "); userInput = keyboard.next(); }
Is there any way to fix the above problem?> oneword
> two word
> >
-
You're having trouble dealing with the end of line token and as such, you may do better getting nextLine() rather than next().
- 08-11-2010, 01:39 AM #3
Member
- Join Date
- Jul 2009
- Posts
- 32
- Rep Power
- 0
Nice, thank you, I knew it would be an easy fix :)
- 08-11-2010, 01:50 AM #4
Similar Threads
-
Using scanner for CSV
By getName() in forum Advanced JavaReplies: 7Last Post: 06-20-2010, 04:33 PM -
Help With Scanner
By jtmoney0511 in forum New To JavaReplies: 10Last Post: 10-12-2009, 11:24 PM -
Scanner
By choko in forum New To JavaReplies: 10Last Post: 01-24-2009, 03:37 PM -
Scanner class problems
By sypherz in forum New To JavaReplies: 6Last Post: 06-09-2008, 09:46 AM -
need help with scanner
By whiterex in forum New To JavaReplies: 1Last Post: 04-22-2008, 01:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks