RosettaCodeData/Task/Detect-division-by-zero/Java/detect-division-by-zero-2.java
Ingy döt Net 86c034bb8b new files
2013-04-10 12:38:42 -07:00

6 lines
220 B
Java

public static boolean except(double numer, double denom){
try{
int dummy = (int)numer / (int)denom;//ArithmeticException is only thrown from integer math
return false;
}catch(ArithmeticException e){return true;}
}