他乃乃地,怎么老出现错误,我机子有问题---------- 编译JAVA程序 ----------
test.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
char ch = (char)System.in.read();
^
1 error
输出完成 (耗时 3 秒) - 正常终止
test.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
char ch = (char)System.in.read();
^
1 error
输出完成 (耗时 3 秒) - 正常终止
try{
char ch = (char)System.in.read();
System.out.println(ch);
catch(IOException ioe ){
System.out.println( "fail" );
}
应该是这样
try{
char ch = (char)System.in.read();
System.out.println(ch);
}catch(IOException ioe ){
System.out.println( "fail" );
}
应该就是没有处理I/O异常吧
《JAVA2应用开发指南》电子工业出版社
作者这么黑啊
public static void main String args[]()throws IOException
{
char ch = (char)System.in.read();
System.out.println(ch);
}
那样的烂书劝你少看,对读者不负责,越看越烦
最近比较晕-_-
try{
String charSet = "GB2312";
java.io.InputStreamReader isr = new java.io.InputStreamReader(System.in, charSet);
java.io.BufferedReader br = new java.io.BufferedReader(isr);
while((String inputMsg = br.readLine()) != null)
{
System.out.println("你输入的是" + inputMsg);
}
}catch(Exception ex){};
核心技术