System.in.read() && java.io.IOException
2021-01-16 16:12
                         标签:运行   style   imp   ring   输出   默认   回车   需要   port        运行程序, 仅输入a, 然后回车,会得到 System.in.read() && java.io.IOException 标签:运行   style   imp   ring   输出   默认   回车   需要   port    原文地址:https://www.cnblogs.com/profesor/p/12924683.htmlimport java.io.IOException;
public class Test
{
    public static void main (String[] args)
    throws IOException
    {
        char a = (char) System.in.read(); //默认接受int,如果需要输出char,需要type cast
        int b = System.in.read(); //这里就不需要type cast了
        System.out.println("a = " + a);
        System.out.println("b = " + b);
    }
}
a = a;
b = 10; // 对应的是line feed的ASCII值
文章标题:System.in.read() && java.io.IOException
文章链接:http://soscw.com/essay/42782.html