hi, this is my hash function, could anyone explain to me why the lines in red are experiencing an "int cannot be deferenced"? Thank you.

public static int hashFunc3(int key) 
{
	int hashVal = 0;
 for (int j=0; j<key.length(); j++) //left to right 
	{
 int letter = key.charAt(j) - 96; //get char code
		hashVal = (hashVal * 27 + letter) % arraySize; //mod
	}
	return hashVal;  //no mod
} //end hashFunc3()

Recommended Answers

All 2 Replies

"key" is an integer, not a String.

"key" is an integer, not a String.

my bad... thanks man.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.