這是一個跟進問題Why is this exception is not printed? Why it's showing an error?
這裏在下面的代碼爲什麼ArithmeticException沒有觸發?爲什麼這裏沒有觸發異常?
class Exp
{
public static void main(String args[])
{
float d,a=1;
try
{
d=0;
a=44/d; //no exception triggered here.. why?
System.out.print("Its not gonna printed a="+a);
}
catch(ArithmeticException e)
{
System.out.println("Print exception"+e);
}
}
}
取而代之的是輸出來自如下:
Its not gonna printed a=Infinity
會發生什麼?