Check to see if a Double value is Infinite in Java
Description
The following code shows how to check to see if a Double value is Infinite.
Example
/*from www . ja v a2 s .c o m*/
public class Main {
public static void main(String[] args) {
double d = (double) 4 / 0;
boolean b1 = Double.isInfinite(d);
System.out.println(b1);
Double dObj = new Double(d);
boolean b2 = dObj.isInfinite();
System.out.println(b2);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »