Double.NaN
System.out.println(Double.NaN == Double.NaN);
System.out.println(((Double) Double.NaN).equals(Double.NaN));
false
true
可以看出来Double.NaN == Double.NaN
的结果是false
,比较时应该用equals
System.out.println(Double.NaN == Double.NaN);
System.out.println(((Double) Double.NaN).equals(Double.NaN));
false
true
可以看出来Double.NaN == Double.NaN
的结果是false
,比较时应该用equals