What am I missing here? http://www.ibm.com/developerworks/java/library/j-pg10255/index.html
In reference to Listing 1: Why is
lamp1 <=> lamp2
equal to a positive number but
"black"<=>"blue"
is a negative number?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a bad example. In the
LavaLamp.compareTomethod the comparison is being built withthison the right-hand side and the other object on left-hand side. The usual convention is the reverse.So when you do
lamp1 <=> lamp2, you’re effectively doinglamp2.baseColor <=> lamp1.baseColor.