beginner programmer having trouble with Scanner and delimiters.
Here is the code that does not work:
import java.util.Scanner;
public class ScannerTester {
public static void main(
String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Enter a double ");
double d = s.nextDouble();
System.out.println("Your double is " + d);
System.out.println("enter some more text\n");
String thisString = s.nextLine();
System.out.println(thisString);
}
}
The problem is that there is no pause to input the string. The method apparently reads something without waiting for keyboard input. I tried changing the new Scanner line to
Scanner s = new Scanner(System.in).useDelimiter("\n");
without success.
Am I right that a delimiter other than default is needed? If so, which one?
Thanks