Hello! This is my first time trying to use Java, and I was trying to learn something with the "Scanner userInput" and ".nextInt()". After I put a bit of code on, it showed me:
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 test.test.main(test.java:14)
This is the code:
package test;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
int name = 0;
Scanner userInput;
userInput = new Scanner(System.in);
name = userInput.nextInt();
System.out.println("Hello" + name + "!");
}
}