Results 1 to 2 of 2
- 11-10-2012, 06: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, 07: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.If you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By dougie1809 in forum New To JavaReplies: 6Last Post: 03-13-2012, 10:25 PM
- By RichersooN in forum New To JavaReplies: 1Last Post: 09-23-2011, 06:14 AM
- By stevisto in forum New To JavaReplies: 1Last Post: 09-15-2011, 02:51 PM
- By thachun in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 09-27-2009, 10:16 AM
- By Singing Boyo in forum New To JavaReplies: 3Last Post: 08-20-2009, 04:57 PM