我剛剛在java中開始了我的大學課程,並一直在使用Scanner類獲取此錯誤。Java掃描錯誤:線程「main」中的異常java.util.NoSuchElementException
import java.util.Scanner;
public class InchConversion
{
public static void main (String[] args)
{
Double inches, centimeters;
Scanner fromKeyboard = new Scanner(System.in);
System.out.println("Enter Value in Inches");
inches = fromKeyboard.nextDouble();
centimeters = inches*2.54;
System.out. println(inches + " inches is equal to " + centimeters + " centimeters.");
}
}
,我不斷收到錯誤是:
Compiling InchConversion.java.......
-----------OUTPUT-----------
Enter Value in Inches
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at InchConversion.main(InchConversion.java:11)
[Finished in 0.8s with exit code 1]
它不會提示輸入它完美對我很好
輸出。 Windows 10.很高興知道它工作正常,你認爲它是一個PC的問題? – theghid