Pregunta de entrevista de LG Electronics

Java Question: What are the differences between a hashcode and equals methods

Respuesta de la entrevista

Anónimo

6 de dic de 2014

hashcode(): This method is used to get unique integer for given object. This integer is used to find bucket when storing in hashmap. By default, This method returns integer representation of memory address where object is stored. equals(): This method is used to simply check the equality between two objects. By default, it checks where two reference refer to same object or not(==).