I'm learning Java and I got some problems when I try input double floating numbers.
Like this.
import java.util.Scanner;
class Program {
public static void main (String[] args) {
Scanner inp = new Scanner(System.in);
double number = inp.nextDouble();
System.out.println(number);
}
}
If I enter 1000 my output will be 1000.0. But if I enter 1000.0, I got this error:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextDouble(Scanner.java:2456)
at test.Test.main(Test.java:6)
Java Result: 1
How could I solve this?