Hash code limit

15 views
Skip to first unread message

Praveen

unread,
Nov 27, 2009, 6:06:14 AM11/27/09
to Technical Discussion
As hash code is an int and it has some limit.

so what happen when we have too many(beyonds the limit of integer)
String objects ??

Is it posible to have two string objects with same hash codes ??

Sandeep Kadyan

unread,
Nov 30, 2009, 10:28:46 PM11/30/09
to technical-...@googlegroups.com
1. What limit you are talking here is it the size limit of int? If yes,  Java generate an int value for hash. So the value will be always in Integer.Min_VALUE and Integer.MAX_VALUE. This causes the hash code generations for two different inputs
 
2. Yes , the two string can have same hashcode. This situation is known as hash collision.  Just try string "My" and "NZ"..Reason is the point one.
 
 
 

Sandeep Kadyan
e-M@il:sandeep...@gmail.com
Skype IM: sandeep.kadyan
YIM: theka...@yahoo.com
Cell:-+91 99116 14500



--
"Knowledge Sharing" The more you share the more you get. :)

You received this message because you are subscribed to the Google Groups "Technical Discussion" group.
To post to this group, send email to technical-...@googlegroups.com
To unsubscribe from this group, send email to technical-discus...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/technical-discussion?hl=en

Reply all
Reply to author
Forward
0 new messages