Pergunta de entrevista da empresa Cisco

equals(), hashCode() in Java

Resposta da entrevista

Sigiloso

25 de fev. de 2012

For Strings == is checking if two strings are identical in memory and "equals" check if they represent the same string (== is harder for strings), for any other object == and equals are the same and check if the objects are the same in memory. hashCode() is a number that will represent the object and will be used in hash table. if two objects are equal they will have the same hashCode, but two not equal objects can still get the same hashCode .