Results 1 to 2 of 2
- 11-10-2012, 05:52 AM #1Member
- Join Date
- Nov 2012
- Rep Power
How do you scan a string with spaces?
How do you input a string that has spaces in it?
For example in this program
System.out.print("Type something: "); Scanner scan = new Scanner(System.in); String x = scan.next(); System.out.println(x);
- 11-10-2012, 06:06 AM #2
Re: How do you scan a string with spaces?
Have you looked at the API for Scanner? There's a method thatAdvances this scanner past the current line and returns the input that was skipped. This method returns the rest of the current line, excluding any line separator at the end.Why do they call it rush hour when nothing moves? - Robin Williams
- By dougie1809 in forum New To JavaReplies: 6Last Post: 03-13-2012, 09:25 PM
- By RichersooN in forum New To JavaReplies: 1Last Post: 09-23-2011, 05:14 AM
- By stevisto in forum New To JavaReplies: 1Last Post: 09-15-2011, 01:51 PM
- By thachun in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 09-27-2009, 09:16 AM
- By Singing Boyo in forum New To JavaReplies: 3Last Post: 08-20-2009, 03:57 PM