So I have the following inputs:
3
3.0
How are you doing
And I need to store them to the following variables:
int myInt
double myDouble
String myString
Here is what I've tried:
myInt = scan.nextInt();
myDouble = scan.nextDouble();
myString = scan.nextLine();
That works for the Integer and Double
value but the String
gave me a NULL value.
Then I tried this:
myInt = scan.nextInt();
myDouble = scan.nextDouble();
myString = scan.next();
Again it worked for the first two, but the string only holds the first word. How can I read the entire string? Do I need to setup a loop?