type of hashtable...

I want to create a hash table having following schema:

for a given tableSize, it creates array of Object class of length tableSize. Every Object in array is actually Vector, to implement binary tree.

here is sample code:

publicstaticclass Roomextends Object{

Vector _node =new Vector();//every room contains a vector, for binary tree implementation

public Room(){

}

publicint insert(int element){

int index=0;

//code here

return index;

}

//gets and sets here...

}

Here how i create this array:

int tableSize = 7;

Room[] hashTable=new Room[tableSize];

int nodeNumber = hashTable[integerToInsert%tableSize].insert(integerToInsert);

Problem is, the last line gives NullPointerException :(

What am I doing wrong? I feel a stupid mistake...

[1576 byte] By [DaniLa] at [2007-11-27 1:49:02]
# 1
Why reinvent the hash table? Why not use a java.util.Map?And your binary tree, could it actually be a java.util.Set?
DrLaszloJamfa at 2007-7-12 1:13:47 > top of Java-index,Java Essentials,Java Programming...
# 2

I am not reinventing hash table, but creating some "mutant" on purpose. I need to stay Vector and Room class. However, Room class can inherit whatever, but it must support

Room[] hashTable= new Room[tableSize];

Moreover, I don't want to use any ready classes like java.util.Map, because with all types of key-value problems, collusions want to deal for myself.

DaniLa at 2007-7-12 1:13:47 > top of Java-index,Java Essentials,Java Programming...
# 3

You created the Room[] array, but you didn't populate it. Until you put something else in there, all the elements in the array will be null.

By the way, you really should use a different name for your array; calling it "hashTable" is always going to cause needless confusion. Call it something like "rooms" instead.

uncle_alicea at 2007-7-12 1:13:47 > top of Java-index,Java Essentials,Java Programming...
# 4
thanks for advice with naming...the thing is, I couldn't understand how to populate my Room class. What is after? Maybe I should put something, typically initialize my Vector in Room class's constructor?
DaniLa at 2007-7-12 1:13:47 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks all, who tried to help. I have found the mistake...
DaniLa at 2007-7-12 1:13:47 > top of Java-index,Java Essentials,Java Programming...