I read in the internet that put() inserts element at the "head" of the linkedlist in case of collisions.
For example:
map location 1 has 1,0 -> 2,0 -> 3,0 -> 4,0 -> null
Now, I will insert an element 5,0 to the linkedlist (I hope hash() returns location 1 value for element 5). After inserting, the location 1 linkedlist will be 5,0 -> 1,0 -> 2,0 -> 3,0 -> 4,0 -> null
Now, I want to update the value of 3 to 30. Therefore I use map.put(KEY = 3, VALUE = 30);
My question is how does put() know whether to update or to insert?
To know if the element is present in the linkedlist, it has to scan the linkedlist. From what I have read in the internet, put() inserts element at the "head" of the linkedlist if there is a collision.
Thanks in advance