Java除以零不会带来算术异常 - 为什么?
2022-08-31 17:05:43
为什么此代码不抛出 ?看一看:ArithmeticException
public class NewClass {
public static void main(String[] args) {
// TODO code application logic here
double tab[] = {1.2, 3.4, 0.0, 5.6};
try {
for (int i = 0; i < tab.length; i++) {
tab[i] = 1.0 / tab[i];
}
} catch (ArithmeticException ae) {
System.out.println("ArithmeticException occured!");
}
}
}
我不知道!