Read double from keyboard in Java

后端 未结 4 541
粉色の甜心
粉色の甜心 2021-01-26 08:50

How can I read a double variable from keyboard in Java? I\'m trying to solve this, but it didn\'t works. It said:

Exception in thread \"main\" java.util.I

4条回答
  •  [愿得一人]
    2021-01-26 09:27

    Tried to reproduce, had no luck. I think that the problem is with your input. here is what I have tried:

    input:

    s
    
    4.51
    
    2
    

    output:

    String: s
    Double: 4.51
    Int: 2
    

    In your code your first scaner takes string, second: double and third takes int.

提交回复
热议问题