We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The String cant read the input immediately after reading the nextDouble()-Because: the input field didn't move from the double input so we cant able to read string. If we have to move the cursor to read string we have to intialize a scan.nextLine()__" between Double and String" -- __ so that the code follows as below import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
double d=scan.nextDouble();
scan.nextLine();
String s=scan.nextLine();
// Write your code here.
Java Stdin and Stdout II
You are viewing a single comment's thread. Return to all comments →
The String cant read the input immediately after reading the nextDouble()-Because: the input field didn't move from the double input so we cant able to read string. If we have to move the cursor to read string we have to intialize a scan.nextLine()__" between Double and String" -- __ so that the code follows as below import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d=scan.nextDouble(); scan.nextLine(); String s=scan.nextLine(); // Write your code here.
}