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.
Java Stdin and Stdout II
Java Stdin and Stdout II
Sort by
recency
|
1178 Discussions
|
Please Login in order to post a comment
import java.util.Scanner;
public class Solution {
}
The compiler can't read the string variable s in the code
`
The compiler can't read the String variable "s" in this code:
public class Solution {
}
I think having to read the nextLine() twice is a bug?
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.
}
it is the actual code cause
afterusing the scan.nextInt(); or scan.nextDouble(); it looks that it is in nextline but its not so ....
import java.util.Scanner;
public class Solution {
}