char a = (char)System.in.read(); 此句怎么会报错!!! 这样就可以了try{ char a = (char) System.in.read();}catch(IOException e){ e.printStackTrace();} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没问题的,可能是你其他地方有错误:下面的例子就没问题!!import java.io.*;class BRRead {public static void main(String args[])throws IOException{char c;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));System.out.println("Enter characters, 'q' to quit.");do {c = (char)br.read();System.out.println(c);} while(c != 'q');}} right!print the error stack trace!Then you can locate the error reason! try { char a = (char)System.in.read(); } catch (IOException e) { System.out.println(e); } 就不会错了 当然,除了RuntimeException外,所有的异常都不能忽略,要么就地处理,要么从函数利throw出去,那样的化,函数要加throws声明。 如何一次性创建多个对象? 一段字符串的含义 请Unix高手给看看? 高手指导下啊,看不明白 子类继承父类在调用时的问题 变量传递的问题 7÷2=4的那个方法是什么? 在开发过程中操作系统的选择 初学者做一个JAVA的课题的问题,非常急!!!!!!!!!!! About InputStream 请教! getResource返回的文件路径含有"%e9%a1%b9%e7%9b%ae",如何读取啊?
下面的例子就没问题!!
import java.io.*;
class BRRead {
public static void main(String args[])
throws IOException
{
char c;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter characters, 'q' to quit.");
do {
c = (char)br.read();
System.out.println(c);
} while(c != 'q');
}
}
char a = (char)System.in.read();
} catch (IOException e) {
System.out.println(e);
}
就不会错了