r/javahelp • • Mar 15 '20

Hashmap

What is the simplest hashmap you can code? I'm thinking of an int[] array with linkedlist at each index? Is there any other way? also please provide code, I'm stuggling to code one perfectly?

0 Upvotes

7 comments sorted by

View all comments

1

u/BS_in_BS Extreme Concrete Code Factorylet Mar 15 '20

The simplest you can code is to use a single array, and use the next free space in the table to store an item on collision. Note this make deleting items tricky.

1

u/Correct_Classroom Mar 15 '20

I'm not taking the case of collision right now..it case of collision it just appends to the last index. So basically with separate chaining