-
May 23rd, 2013, 01:46 AM
#1
How To Enter Name with Whitespaces in a String Variable
Hi Team,
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".
String 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 ;
import java.util.Scanner;
public class Stringtwo
{
public static void main(String[] args)
{
String name;
Scanner scannedInfo=new Scanner(System.in);
name=scannedInfo.next();
System.out.println(name);
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|