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' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -