做了点小修改:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@SuppressWarnings("serial")
class Exception123 extends Exception {
public String toString() {
return "由字符串123所引起的例外";
}
}
public class E1401 {
public static void main(String args[]) throws IOException {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
if (str.equals("123")){
throw new Exception123();
}
System.out.println(str);
} catch (Exception123 e) {
System.out.println(e.toString());
} finally {
System.out.println("程序结束");
}
}
}
运行结果:
123
由字符串123所引起的例外
程序结束
取消
评论
如果觉得《java编译时文件是什么 JAVA编译出现 进行语法解释时已抵达文件结尾 是什么意思?...》对你有帮助,请点赞、收藏,并留下你的观点哦!