我正在使用Java语言做一些小实践,并坚持使用这些语言:
import java.util.Scanner;
public class nhap {
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
double n;
n= sc.nextDouble();
System.out.println(1.0/n);
}
}
当我尝试输入double类型的数字时。它显示了此错误:
0.56
Exception in thread "main" java.util.InputMismatchException
at java.base/java.util.Scanner.throwFor(Unknown Source)
at java.base/java.util.Scanner.next(Unknown Source)
at java.base/java.util.Scanner.nextDouble(Unknown Source)
at nhap.nhap.main(nhap.java:10)
我正在寻找一些可以帮助我解决此问题的建议:)