Java:找不到符号

Suk*_*bir 2 java tostring nan

在Javadoc中写道:

public static String toString(double d)

返回double参数的字符串表示形式.下面提到的所有字符都是ASCII字符.

如果参数是NaN,则结果是字符串"NaN".

但是当我编译下面的代码时,它会给出错误:找不到符号NaN

String intStr2 =Double.toString(NaN); 
Run Code Online (Sandbox Code Playgroud)

Sat*_*ish 8

由于NaN未定义,因此会抛出编译错误,使用以下方法来克服同样的错误,

String intStr2 = Double.toString(Double.NaN);
Run Code Online (Sandbox Code Playgroud)