I’m trying to read two integers on the same line.
Scanner a=new Scanner(System.in);
x=a.nextInt();
y=a.nextInt();
Now, if I input
3 4
3 4
x = 3 and y = 3. I even tried using a.useDelimiter(“\\s”) but it doesn’t work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There must be an error elsewhere in your code. It works fine for me.
Input:
Output:
See it working online: ideone