Ebay Interview Question
Software DevelopersCountry: United States
Equals() is a 'standard' method of the 'object' class. Default implementation for reference types is reference equality. If you need a smarter way of equality comparison, you need to override it and, probably, implement complex and expensive equality comparison.
In addition to hash table data structure, hash codes also might be used for easier objects comparison. However it doesn't substitute it completely (because of collisions): so, if the hash values are equal you could call a real 'full' equality comparison.
Equals function is used to compare string object to a specified object. If returns true if the string object consist of same character sequence as specified object.
Initially hashcode returns hexadecimal location of the object. It also uses computation formula to calculate hashcode for string object.
The usage of equals and hashcode functions are used widely in hashing an object into any hash store such as hashmap.
- Prashanth July 14, 2015equals function is used to compare two objects of the same type.
hashcode function is used to generate the unique location to be used to insert the object into a hashmap.