I have read up quite a bit on these and am still rather confused on one aspect. HashMaps take in a K,V pair. Why is this necessary?
For example I want to add "abracadabra" to HashMap myMap.
Would it not use String.hashCode() function as the key, and then "abracadabra" as the value?
And then if I were trying to lookup if "abracadabra" is there it would check if the 'bucket' for that hashCode is nonempty, and if it is then iterate through everything in that 'bucket' (At worst O(n)...but not in reality). So what I am saying is wouldn't the objects .hashCode() function be the key and the object is the hashcode? Why is an explicit Key necessary to be declared?
What is the purpose of having K,V pair? I have had this explained to me multiple times and have read multiple articles/examples/etc. and I still can't get it through my thick skull.