所以我有一些带有扫描仪的 Java 代码。当我遇到错误时,我做错了什么。
// Creates a "scanner" for the input
Scanner readInput = new Scanner(System.in);
// Print out random integer and open close message.
System.out.println("Printing Random Numbers between 1-200: ");
int guess = readInput.nextInt();
错误(我对 Java 还很陌生,我的代码有点像 4-5 年前的代码。但忘记了):
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at main.files.mian.main(mian.java:30)