3
Why this generates an Arithmeticexception / by zero:
for (int i = 1; i <= 5; i++) {
System.out.println(i);
int a = i / 0;
System.out.println(a);
}
And that’s not (print "Infinity")?
for (int i = 1; i <= 5; i++) {
System.out.println(i);
double a = i / 0.0;
System.out.println(a);
}
I found this: https://stackoverflow.com/questions/12954193/why-does-division-by-zero-with-floating-point-or-double-precision-numbers-not
– Andrei Coelho
After I understood that dividing by
0.0
gives Infinity. That’s why I deleted my answer.– Andrei Coelho