How To Enter Name with Whitespaces in a String Variable
I am wondering how to enter a string with White Space and Store it in a String variable.
For example : I have created a string named "name".
I want to Store "Michael Jackson" in the String "name". I couldn't do it. My program Just accepts Michael and not Jackson.
here is my code ;
public class Stringtwo
public static void main(String args)
Scanner scannedInfo=new Scanner(System.in);
Re: How To Enter Name with Whitespaces in a String Variable
1. Please use code tags! http://forums.codeguru.com/misc.php?do=bbcode#code
2. Scanner's next() method reads the next token delimited by default delimiter which is space. To read the whole line use nextLine() method.