Discussion :: Objects and Collections - Pointing out the correct statements (Q.No.3)
Jjj said: (Sep 14, 2015) | |
Two new empty String objects will produce identical hash codes. The above will produce unique hash codes right and therefore its incorrect or am I wrong? |
Radistao said: (Dec 5, 2015) | |
Damn, guys, hashCode(), not hashcode() - JAVA METHODS ARE CASE SENSITIVE! |
Ford Prefect said: (Jul 18, 2016) | |
The question is asked in a confusing way. The text should be changed from "incorrect" to "correct" and the answer should be inverted. Also, it's hashCode () not hashcode (). |
Hepbo3Ah said: (Jul 20, 2016) | |
@Jjj you are correct. Two empty strings do produce identical hashCode(). Also, some Collections DO use hashCode() to store help locate the data, namely HashMap. Its even has a "hash" in its name. Terrible question |
Avinash said: (Oct 5, 2016) | |
Every object uses hashCode, why only for some collections? |
Sat said: (Dec 15, 2016) | |
The hashCode always return positive int value, not a negative value, or float or double etc then how the #2 is wrong? As #3 as for giving string class inherit hashCode() from object class that is correct because it is mentioned to inheritance not for how the hashCode is calculated for a string? |
Post your comments here:
Name *:
Email : (optional)
» Your comments will be displayed only after manual approval.