java hash table code
JAVA Hashinsh.. is my code correct?
Create a method that will hash a String Value to an int key. The parameters to this method should
be the Value, and the size of the hash table (M) that you’ll use for determining the hash key.
public void hash(String Value, int size){
String[] hashtable = null;
hashtable = new String[size];
for(int x=0; x
int key = Value.hashCode();
}
Um. No.
public int hash(String value, int m) {
return value.hashCode() % m;
}
CS 61B Lecture 4: Types and Conditionals
Categories: Uncategorized