Java Stdin and Stdout II

  • + 1 comment

    Solution:

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        Double d = scan.nextDouble();
        scan.nextLine();  // adding this as after reading double value it adds \n  to indicate end of buffer to the scan 
        //so reads the same  empty string if we dont mention
                //so above that /n is consumed
        String s=scan.nextLine();
    
        // Write your code here.
    
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }