I have some confusion with respect to the working of Hashmap.
What is know about the working of a hashmap is that when a hashmap is created a array of linked list is created i.e. each element that is added to the hashmap the hashcode is calculated of the key object that hashcode is the index in the array at which the element would be added to the linked list.
My doubt here is that suppose i have some code where i am adding 2 objets to a hashmap one hashmap returns returns the hashcode 1 and the element will be added to the linked list at index - 1. Now if i am adding another element whose hashcode returned is suppose INT.max_value or very large number so will the array of linked list be of size this much (INT.max_value or very large number) ??
Welcome to the Ranch
I am afraid you have posted in the wrong location. I am sure Henry who moderates this forum won’t mind if I move your post somewhere more appropriate.
The array in a HashMap defaults to 16 length; this discussion is about how the hash codes are converted to array indices. If you need to know any more, be sure to ask.
Also, EaseUp (←click on the link). Putting "Urgent" in your subject line does not usually get it the kind of attention you want. We're all volunteers here and if anyone wants to reply, they will reply in their own time. I have edited the subject and removed "Urgent".
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
Now if i am adding another element whose hashcode returned is suppose INT.max_value or very large number so will the array of linked list be of size this much (INT.max_value or very large number) ??
You have the wrong idea, hashcodes are just the start of getting the index. You should study the ACTUAL code in HashMap instead of speculating. One of the great things about Java is that the standard library code is published. Here for example is HashMap put method:
Use the Source!
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF