J
jlukar
The javadoc says the formula to calcuate the hashCode for String is:
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
this can result in negative numbers which is not desirable for me.
Any idea folks ?
Second question:
I am counting on hashCode to help me with generating a unique Integer
key using two concatenated strings the combination of which is
gauranteed to be unique. .
e.g.
("LASTNAME"+"."+"EMPLOYEE-CATEGORY") will always be unique.
so
("LASTNAME"+"."+"EMPLOYEE-CATEGORY") .hashCode() is what I wanted to
use.
will above hashCode() always be unique given that the string
combination used to generate it is unique ?
help???
k.
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
this can result in negative numbers which is not desirable for me.
should be generated.From the formula this is not clear why as always positive number
Any idea folks ?
Second question:
I am counting on hashCode to help me with generating a unique Integer
key using two concatenated strings the combination of which is
gauranteed to be unique. .
e.g.
("LASTNAME"+"."+"EMPLOYEE-CATEGORY") will always be unique.
so
("LASTNAME"+"."+"EMPLOYEE-CATEGORY") .hashCode() is what I wanted to
use.
will above hashCode() always be unique given that the string
combination used to generate it is unique ?
help???
k.