+ 2
Why a double on division with 0.0 doesn't give an Arithmetic Exception. Rather shows Infinity?
Hii, While practicing and understanding java i got to know about the Arithmetic Exception "divide by 0". I tried throwing this exception myself by dividing a double var with a 0.0, however it showed infinite in both the cases (forcible throwing both runtime and compile time exception failed miserably). Can you please explain why did this happen? When does it give out the exception, when does it print "infinte". https://code.sololearn.com/c881zMZK76bw/?ref=app
2 ответов
+ 3
You may have a look at this:
https://www.baeldung.com/java-division-by-zero
+ 1
That trick works in other languages, but not java. I think it is wrong for java to give a single valid result since the result of dividing by zero is mathematically ambiguous.