Why does Double.NaN==Double.NaN return false?
问题 I was just studying OCPJP questions and I found this strange code: public static void main(String a[]) { System.out.println(Double.NaN==Double.NaN); System.out.println(Double.NaN!=Double.NaN); } When I ran the code, I got: false true How is the output false when we're comparing two things that look the same as each other? What does NaN mean? 回答1: NaN means "Not a Number". Java Language Specification (JLS) Third Edition says: An operation that overflows produces a signed infinity, an operation