What is the time complexity of Java hashCode method for the String class? -


is java's hashcode method string class computed in constant time or linear time? algorithm used?

the documentation tells function:

s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]

it's computed once using linear-time pass, , cached it's o(1) retrieve in future.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -