throwexception3.java
来自「JAVA的例子程序」· Java 代码 · 共 19 行
JAVA
19 行
public class ThrowException3{
int x;
void throw1()throws ArithmeticException{
x=0;
x=3/x;
x=1;
System.out.println("x="+x);
}
public static void main(String[] args){
ThrowException3 c=new ThrowException3();
try{
c.throw1();
}catch(Exception e){
System.out.println("begin to catch exception");
System.out.println("get message="+e.getMessage());
}
System.out.println("program ends ok");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?