Java Data Type Tutorial - Java Float.isNaN(float v)








Syntax

Float.isNaN(float v) has the following syntax.

public static boolean isNaN(float v)

Example

In the following code shows how to use Float.isNaN(float v) method.

//from  w  ww .  j  a v  a2 s .  com
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 + " = " + Float.isNaN(f1));
     System.out.println(f2 + " = " + Float.isNaN(f2));
   }
}

The code above generates the following result.