In java, “5/0” statement doesn't fire SIGFPE signal on my Linux machine, why?

后端 未结 6 1729
庸人自扰
庸人自扰 2021-01-18 17:04

I wrote a very simple c program:

#include

int main(){
    int a=2;
    int b=0;
    printf(\"%d\\n\", a/b);
}

and run it wi

6条回答
  •  猫巷女王i
    2021-01-18 17:46

    Java runs in a virtual machine (the JVM), which abstracts the hardware from the program. Most errors in a Java program will cause Java Exceptions and not trigger any native cpu or os error codes. I'd guess this code will throw an ArithmeticException (or something like that).

提交回复
热议问题