为什么使用int a = Integer.parseInt(System.in.read())时不能将字符串转换为int类型;

时间:2020-03-05 14:14:59

标签: java runtime-error

我无法理解问题出在哪里,因为System.in.read()不给ascii字符串,所以使用Integer.parseInt必须解决它,并且必须返回在控制台上输入的值。.

我在编译时抛出错误,无法将String转换为int类型。

请检查并告诉我哪里出了问题。

import java.io.IOException;

class AB 
{
    public static void main(String[] args)throws IOException 
    {
        int a = Integer.parseInt(System.in.read()); 

        System.out.print(a);
    }
}

0 个答案:

没有答案
相关问题