mardi 31 mars 2015

Core Java on division by 0.0

I heard one twist in java. If anyone know proper reason you're asked to share it. Question is:



double result1 = 1.0/0.0;
sop(result1); // output Infinity
double result2 = 0.0/0.0;
sop(result2); // output NaN


the same is happening for float variable also. but for int type its raising ArithmeticException. Why?


Note: I am using jdk 1.7


Aucun commentaire:

Enregistrer un commentaire