Bear Bibeault wrote:
Prashant Mumbarkar wrote:So I was wondering what technology/language we can use to bypass Google's algorithm if it is at all possible or at least we can help to rank our website significantly higher in search.
(a) Even if this were possible, does this not strike you at all as unethical?
(b) If it were possible, do you not think that everyone would be doing it? And then what would be the point?
Jesper de Jong wrote:Remember the rule that hashCode() and equals() have to follow:
If two objects A and B are equal (calling A.equals(B) and B.equals(A) returns true), then their hash codes must be the same (A.hashCode() == B.hashCode()).
(If the equals() and hashCode() methods of the class of A and B don't follow that rule, then they are implemented incorrectly).
Note that the rule only works one way: it does not mean that if A and B are not equal, their hash codes must be different - they can still be the same.
Now, think about what it means. It means that if you have two objects A and B, and you compare their hash codes, and you find that their hash codes are different, then you can be sure that A and B are not equal. (Because if they are equal, their hash codes must be the same). So, HashMap doesn't always have to call equals() to know that two objects are different - when it sees that the hash codes are different, it already knows the objects are different, and it doesn't need to call equals().
Matthew Brown wrote:The last one you are looking up with exactly the same key as it was added - the same object. So even the non-overridden versions of equals() will return true and hashCode() will return the same value.
Rob Spoor wrote:
Don't ever do that unless you are certain that you won't get overflow. Suppose this.moofValue is Integer MIN_VALUE and otherMoof.moofValue is 1. The result will be Integer.MAX_VALUE, not a negative value. If you ever need to compare two ints, use Integer.compare(x, y). Likewise for Long, Float and Double. For byte, char and short (where overflow won't happen) you can choose between simple subtraction and using the static compare method (the static methods use simple subtraction).
Piet Souris wrote:correct!
but, with Henry:
3) ... // how would you determine which of two int's is the bigger one?
Greetz,
Piet