Home > Back-end >  NextInt () input error
NextInt () input error

Time:09-17


Package com. Example. IO;

import java.util.Scanner;

Public class MyClass {
Public static void main (String [] args)
{
Scanner sin=new Scanner (System. In);
Int a=sin. NextInt ();
System.out.println(a);
System. The out. Println (" a ");
}
}
The small white is very confused,,, this is what complains,,,
Error nextInt () there is a problem but why
The Exception in the thread "main" Java. Util. NoSuchElementException
At Java. Util. Scanner. ThrowFor (862) Scanner. Java:
At Java. Util. Scanner. Next (1485) Scanner. Java:
At Java. Util. Scanner. NextInt (2117) Scanner. Java:
At Java. Util. Scanner. NextInt (2076) Scanner. Java:
At com. Example. Helloapplet. HelloWorldApplet. Main (HelloWorldApplet. Java: 11)

FAILURE: the Build failed with an exception.

CodePudding user response:

It should be the input you have any question, you entered is not an Int type number,

CodePudding user response:

I haven't input should not be... It is an error directly

CodePudding user response:

refer to the second floor qq_40722414 response:
I haven't input should not be... It will direct error


Basically won't without input error, pay attention to whether the keyboard,

CodePudding user response:

The keyboard is good no problem! Write c from need of keyboard input,

CodePudding user response:

reference 4 floor qq_40722414 response:
keyboard is good no problem! Write c from the need of keyboard input,


There is only one possible your JDK has a problem, certainly no problem, change the JDK version and see,

CodePudding user response:

You see you have what the class 11 lines, errors have the
At com. Example. Helloapplet. HelloWorldApplet. Main (HelloWorldApplet. Java: 11)

CodePudding user response:

Com. Example. Helloapplet. HelloWorldApplet. Main (HelloWorldApplet. Java: 11)
Obviously not run your class code, check operation

CodePudding user response:

The elements of sin has not int

CodePudding user response:

You must be running, in the console input has a value of type int, the code itself is no problem,

CodePudding user response:

references 9 f aw277866304 response:
you must be running, in the console input has a value of type int, the code itself is no problem,

CodePudding user response:

Java. Util. When two NoSuchElementException will trigger
1: hand slide wrote two next () method call
2: call System. In. The close () closed object in
Check whether the code for the above operation, no word is JDK has a problem, to download a

CodePudding user response:

The
reference 2 floor you Naive! Response:
I haven't input should not be... It will direct error
no, as long as you write so, input type int is no problem,

CodePudding user response:

Not a class

CodePudding user response:

The
refer to the original poster you Naive! Response:
package com. Example. IO;

import java.util.Scanner;

Public class MyClass {
Public static void main (String [] args)
{
Scanner sin=new Scanner (System. In);
Int a=sin. NextInt ();
System.out.println(a);
System. The out. Println (" a ");
}
}
The small white is very confused,,, this is what complains,,,
Error nextInt () there is a problem but why
The Exception in the thread "main" Java. Util. NoSuchElementException
At Java. Util. Scanner. ThrowFor (862) Scanner. Java:
At Java. Util. Scanner. Next (1485) Scanner. Java:
At Java. Util. Scanner. NextInt (2117) Scanner. Java:
At Java. Util. Scanner. NextInt (2076) Scanner. Java:
At com. Example. Helloapplet. HelloWorldApplet. Main (HelloWorldApplet. Java: 11)

FAILURE: the Build failed with an exception.


Compiler error, could not compile your project file: FAILURE: Build failed with an exception. The reason is the main way to HelloWorldApplet class there is an error, you check HelloWorldApplet, it is located under your current project, although you is not the purpose of running the class, but it has the wrong words will influence the compilation
  • Related