I have these very simple 3 lines of code which, to my understanding, should allow the user to enter a decimal number and then spit the number out.
System.out.print("Enter a number.\n");
double number = input.nextDouble();
System.out.println(number);
When I do however enter a decimal number Java throw an InputMismatchException; although when I enter en integer the number it spits out show a decimal place. This is so simple I couldn’t even google it, and yet I’m completely lost.
EDIT Wait what? I just tried and it actually accepts “2,4” but not “2.4”. Can that be changed?
You need to change the locale (I assume you are using a Scanner):