+ 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??
12 odpowiedzi
+ 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);
0
I already imported the class package and created an object and initialized a variable but still the problem
0
I updated the code and still not working
0
you mean that the input can be entered only once when the code executed first time right?
0
you are right but it doesn't make me guess
0
I played it on intellij and it was funny