I am trying to run below program and expecting Arithmetic Exception
because we are dividing double value by zero but getting Infinity as output
.
This is below program. But if we are using int instead of double then getting Arithmetic Exception
public static void main(String z[]) {
Double a = 10.0;
Double b = 0.0;
System.out.println(a/b);
}
Output: Infinity
public static void main(String z[]) {
int a = 10;
int b = 0;
System.out.println(a/b);
}
Output:
Exception in thread "main" java.lang.ArithmeticException: / by zero
at (Test.java:94)
Can someone please explain why we are getting Infinity for Double value?