各位大侠,请看:
我让Java计算1.0/0,分母是0,按理说应该抛出异常,执行System.out.println("Invalid denominator");才对但最后得到的结果却是Infinity,求解!谢谢!
public class Main {
public static void main(String[] args){
try{
System.out.println(1.0/0);
}
catch(ArithmeticException e){
System.out.println("Invalid denominator");
}
}
} |
|