the hashfunc (method is not as efficient as it might be aside from the character conversionthere are two multiplications and an addition inside the loop we can eliminate multiplication by taking advantage of mathematical identity called horner' method (horner was an english mathematician - this states that an expression like var * var * var * var * var * can be written as (((var * var )* var )* var )* var to evaluate thiswe can start inside the innermost parentheses and work outward if we translate this to java method we have the following codepublic static int hashfunc (string keyint hashval for(int = <key length() ++/left to right int letter key charat( /get char code hashval hashval letter/multiply and add return hashval arraysize/mod /end hashfunc (here we start with the leftmost letter of the word (which is somewhat more natural than starting on the right)and we have only one multiplication and one addition each time through the loop (aside from extracting the character from the stringthe hashfunc (method unfortunately can' handle strings longer than about letters longer strings cause the value of hashval to exceed the size of type int (if we used type longthe same problem would still arise for somewhat longer strings can we modify this basic approach so we don' overflow any variablesnotice that the key we eventually end up with is always less than the array sizebecause we apply the modulo operator it' not the final index that' too bigit' the intermediate key values it turns out that with horner' formulation we can apply the modulo (%operator at each step in the calculation this gives the same result as applying the modulo operator once at the endbut avoids overflow (it does add an operation inside the loop the hashfunc (method shows how this lookspublic static int hashfunc (string keyint hashval for(int = <key length() ++/left to right int letter key charat( /get char code hashval (hashval letterarraysize/mod return hashval/no mod /end hashfunc (