在我的代码中,我试图在 eclipse java 中处理算术异常。我的代码在 Windows 中运行良好,但在 Mac 中出现了一些致命错误,尽管它对于 IndexOutOfBound 等其他类型的异常运行良好。而且我不知道是什么问题。所以下面是我的代码和正在显示的错误。
public class ExceptionHandling {
public static void main(String[] args) {
try{
int num1=30, num2=0;
int output=num1/num2;
System.out.println ("Result: "+output);
}
catch(ArithmeticException e){
System.out.println ("You Shouldn't divide a number by zero");
}
}
}
谢谢,这似乎是一个愚蠢的问题,但我会提前感谢您的帮助。