【发布时间】:2014-12-20 05:33:53
【问题描述】:
作为一名学生,我正在编写 2 年的程序。我只是好奇什么时候会出现 catch 语句。我尽一切努力让我的程序输出 catch 块内的语句,但我失败了。有什么想法吗?
try{
System.out.print("Enter a sentence: ");
String sentence = dataIn.readLine();
String res = sentence.replaceAll(" ", "");
System.out.println(res);
}catch(IOException e){
e.printStackTrace();
System.err.println(e);
}
}
【问题讨论】:
标签: java exception-handling error-handling