Check if a Float is Infinite in Java
Description
The following code shows how to check if a Float is Infinite.
Example
/* ww w . ja v a2 s . co m*/
public class Main {
public static void main(String[] args) {
float f = (float) 1 / 0;
boolean b1 = Float.isInfinite(f);
System.out.println(b1);
Float fObj = new Float(f);
boolean b2 = fObj.isInfinite();
System.out.println(b2);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »