Alright I need to develop a hash table using an array that can only hold 10 items. The program will not store the usernames but rather only the passwords in an array. The index will be generated by taking the username and hasing it. I think I have my hashing function

Java Code:
	public int hash_function(String key) {

		int KeyVal = 0;

        for (int i=0; i<key.length(); i++) {
            KeyVal += key.charAt(i);
        }		
		int index = 0;
		for(int i = 0; i < key.length(); i++){
			index = KeyVal%10;
			}
		if (database[index] == null){
		return index;
		}
		else
			hash_function(key + "Qvc" + KeyVal);
	} // end of hash_function
My problem is two fold. How can the program tell me if a username has been used before if it is not stored in the program. Also how can I retrieve data from the table if the algorithm is set up to call itself again if the index it returns is full?