0

Hi I just installed (multiple times) Netbeans 8.2 (jdk1.8.0_221) and I am facing a problem with decimal variables. I make it short:


package bbbbb;
import java.util.Scanner;
public class Bbbbb 
{
    static Scanner input = new Scanner(System.in);

    public static void main(String[] args) 
    {
        double a;
        a = input.nextDouble();
        float b;
        b = input.nextFloat();
        System.out.println(a+b);
    }

}

And I am facing this issue after placing decimal numbers (for double and float as well):

55.5
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 bbbbb.Bbbbb.main(Bbbbb.java:11)
C:\Users\Żyrafka\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 3 seconds)


Mario
  • 1
  • The exception states that *Thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type.* so what was your input? – Themelis Feb 11 '20 at 11:53
  • 1
    You seem to be on a system, where the decimal separator is not a dot but rather something else (usually the comma). Try it with 55,5 instead of 55.5 – Joachim Rohde Feb 11 '20 at 12:11
  • Themelis - my input there was 55.5 basically any decimal number has the same error – Mario Feb 11 '20 at 12:41
  • when I have insert coma run: 33,66 42,77 76.43000045776367 BUILD SUCCESSFUL (total time: 11 seconds) it looks work thank you – Mario Feb 11 '20 at 12:47
  • Does this answer your question? [Netbeans using comma as default. Why?](https://stackoverflow.com/questions/58457466/netbeans-using-comma-as-default-why) – skomisa Feb 11 '20 at 21:02
  • The decimal separator to be used is either implicitly specified (based on the JVM's locale), or explicitly specified by you. See the linked duplicate for three different approaches for setting locale in NetBeans. – skomisa Feb 11 '20 at 21:07

0 Answers0