HashTable - Array changing size in middle of rehashing

I'm not sure what is going on with my HashTable. But I have it to where if the array is more than half full, then it will rehash and put the non-empty values into a new array of double size. But for some reason mid rehashing, the array seems to revert back to the original size so Im getting and IndexOutofBounds error and I'm not sure why...

Heres the code I got:

public class HashTable {

public static void main(String[] args) {

HashTable table = new HashTable(13);

table.addItem(5, table.theTable);

table.addItem(23, table.theTable);

table.addItem(17, table.theTable);

table.addItem(8,table.theTable);

table.addItem(24, table.theTable);

table.addItem(15, table.theTable);

table.addItem(2, table.theTable);

table.addItem(46, table.theTable);

table.displayTable();

}

int...

Read More »

By: StackOverFlow - Wednesday, 7 November

Related Posts