我有以下代码:
public static void main(String[] args) {
try {
int d1 = 3;
int d2 = 0;
int d = d1/d2;
} catch (Exception ex) {
System.out.println("Exception");
}
}
Run Code Online (Sandbox Code Playgroud)
运行此代码时,很明显会发生异常.但是,如果我更改代码如下:
public static void main(String[] args) {
try {
double d1 = 3;
double d2 = 0;
double d = d1/d2;
} catch (Exception ex) {
System.out.println("Exception");
}
}
Run Code Online (Sandbox Code Playgroud)
然后异常不抛出.我真的不明白.有人可以详细说明吗?
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |