Java Stdin and Stdout II

  • + 0 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.

    System.out.println("String: " + s);
    System.out.println("Double: " + d);
    System.out.println("Int: " + i);
    

    }