System.in.read() method

后端 未结 6 1382
太阳男子
太阳男子 2020-12-02 03:03

Following is the code, I have written to get two inputs from user. But when I run the program, It takes only one input and generate other by itself and calculate the wrong v

6条回答
  •  我在风中等你
    2020-12-02 03:44

    simply put -

    int x = System.in.read();
    

    automatically throws an exception.

    • you allocated and defined a memory cell to hold an int, then assigned a byte to be stored there. Recast the input or use a diff. input method.

提交回复
热议问题