I want to read a double number from standard input, but I always get this exception:
java.util.InputMismatchException
import java.util.Scanner;
public class ScanDouble {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double d = scan.nextDouble();
System.out.println("Double: " + d);
}
}
If the input is integer it's okay, but when double, I get the exception.
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextDouble(Scanner.java:2413)
at ScanDouble.main(ScanDouble.java:10)
No comments:
Post a Comment