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