Java Data Type Tutorial - Java Float.isInfinite()








Syntax

Float.isInfinite() has the following syntax.

public boolean isInfinite()

Example

In the following code shows how to use Float.isInfinite() method.

// w w  w  . ja  v a 2s. c  o  m
public class Main {

   public static void main(String[] args) {

     Float f1 = new Float(1.0/0.0);
     Float f2 = new Float(0.0/0.0);
  
     System.out.println(f1 + " = " + f1.isInfinite());
     System.out.println(f2 + " = " + f2.isInfinite());
   }
}

The code above generates the following result.