less than 1 minute read

When comparing variable, let’s call it x to itself, the result should be true, right? Especially in Java, language that is well designed, and doesn’t behave like JS (as you can see here). Or isn’t it? Consider this snippet:

@Test
public void testCompareWithItself(){
    double d = Double.NaN;
    assertFalse(d == d);
}

The test passes! How? Check this thread for more information.