I learning about hash tables from "data structres and algorithems in java" and there is a concept I couldn't understand. for example, I want to build an phone book. I want a hashtable which gets name of person as a key and spit back his phone. I understood how to make an hash function to create from the person's name a numerical index. But after I inserted the name of the person to the hash table by his numerical index, how can I get his phone? how can I connect between this keys and values?
Im trying to implementing my own hash-table and not use the java api
You should store a key-value pair in the hash table, not just key. The setter methods accept key/value pair, wrap them into key/value pair instance and store in the bucket. Access methods calculate bucket index based on key and iterate through pairs looking for the one having exact key. May be class Map.Entry can give you some ideas.