首先,我在Java中竞争noob。我试图获得用户输入。每当我尝试输入双变量时,Eclipse都会显示此错误:
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.nextDouble(Unknown Source)
at lesson1.MyClass.main(MyClass.java:10)
到目前为止,这是我的代码:
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner scan1 = new Scanner(System.in);
System.out.println("Enter some decimal value");
double userInput = scan1.nextDouble();
System.out.println("The entered value is ");
System.out.print(userInput);
}