This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by P Ventura: ...why the following code prints "True"? It's a comparison between two constants!? ...
Actually, it prints "False."
Yes, these are "constants," but they are constants representing things that are Not a Number. And because these are not real numbers, they cannot be compared in a real ordinal manner. That is, from a real number perspective, we can't say that one is greater than, less than, or equal to another. So these operations return false (with the exception of NaN != NaN, which must return true since NaN == NaN returns false).
For example, consider that NaN might represent Math.sqrt(-1), or it might represent Math.sqrt(-987654). Neither of these are real numbers, but they're not equal either.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org