How to specify decimal delimiter

前端 未结 3 406
遥遥无期
遥遥无期 2021-01-26 01:26

I have a fairly simple problem. I am getting real-number input like6.03, but that gives me errors. If I change it to 6,03, it\'s ok. I, however, can\'t

3条回答
  •  一个人的身影
    2021-01-26 01:56

    Scanner can be provided with Locale to use, you need to specify Locale that uses . as decimal separator:

    Scanner sc = new Scanner(System.in).useLocale(Locale.ENGLISH); 
    

提交回复
热议问题