集册 Java实例教程 如何使用Float类的isNaN()方法。

如何使用Float类的isNaN()方法。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

433
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
如何使用Float类的isNaN()方法。
/* 来 自 n o w    j a v a  . c o m*/


 

public class Main {

 

  public static void main(String[] args) {

   

    /*

     It return true if the specified argument is Not-a-Number value, false otherwise.

    */

    float f = (float) Math.sqrt(-10);

    boolean b1 = Float.isNaN(f);

    System.out.println(b1);

 

    /*

     boolean isNaN() instance method checks whether the Float object is

     Not-a-Number value or not.

     It return true if the object is Not-a-Number value, false otherwise.

    */

    Float fOb
展开阅读全文