+ 1

Why nextInt() method of the Scanner object in java not working here?

I tried to use the nextInt() method of the java Scanner class but it seems that it's not working here and gave me a noSuchElement exception, what can I do??

12th Jan 2018, 4:38 PM
Mostafa Fayed
Mostafa Fayed - avatar
12 Respostas
+ 2
I will tell you syntax //first line of your code import java.util.Scanner; // Creating object of scanner class Scanner input = new Scanner (System.in); // Taking input int a = input.nextInt(); //Display the input System.out.print(a);
12th Jan 2018, 4:48 PM
Hrishikesh Kulkarni
Hrishikesh Kulkarni - avatar
0
I already imported the class package and created an object and initialized a variable but still the problem
12th Jan 2018, 4:52 PM
Mostafa Fayed
Mostafa Fayed - avatar
12th Jan 2018, 5:31 PM
Mostafa Fayed
Mostafa Fayed - avatar
0
I updated the code and still not working
12th Jan 2018, 6:49 PM
Mostafa Fayed
Mostafa Fayed - avatar
0
you mean that the input can be entered only once when the code executed first time right?
12th Jan 2018, 6:51 PM
Mostafa Fayed
Mostafa Fayed - avatar
0
you are right but it doesn't make me guess
12th Jan 2018, 6:58 PM
Mostafa Fayed
Mostafa Fayed - avatar
0
I played it on intellij and it was funny
12th Jan 2018, 7:07 PM
Mostafa Fayed
Mostafa Fayed - avatar