📄 exceptiondemo3.java
字号:
public class ExceptionDemo3
{
public void 输入分数(int 分数) throws Exception
{
if(分数 >100) throw new Exception("分数太高");
if(分数 < 0) throw new Exception("分数太底");
System.out.println("分数是 = " + 分数);
}
public static void main(String arg[])
{
ExceptionDemo3 demo = new ExceptionDemo3();
try{
demo.输入分数(90);
demo.输入分数(80);
demo.输入分数(190);
demo.输入分数(-90);
}catch(Exception e){
System.out.println("您输入的成绩有错误,程序退出");
e.printStackTrace();
}
System.out.println("程序执行完毕,退出!");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -