Thanks Raghu. Please refer our KZbin channel to your friends circle as it might be helpful for them. Happy learning.
@shafivullar41808 жыл бұрын
Explanation is simple and so nice
@prabashyd45045 жыл бұрын
superb Explanation bro.
@SivaReddyJavaTechie5 жыл бұрын
Thanks Prabas. Please refer our KZbin channel to your friends as it might be helpful for them. Happy Learning.
@josephkumar91123 жыл бұрын
Thank you For the Video...🙂
@SivaReddyJavaTechie3 жыл бұрын
Thanks Joseph. Please share our youtube channel with your friends and colleuges as it may helpful for them. Happy Learning.
@kumaragniveshverma81347 жыл бұрын
All content are appreciable, except hashCode and equal method implementation u r looking confused on both the method.
@rahulsrivastava25787 жыл бұрын
After size is increased the what how does the values are stored with new size as suppose i had 4 value on index 2 and now my map is increased to 32 capacity then whether any value from 4 will be distributed to some other bucket and if yes then how
@ravikrishnas76658 жыл бұрын
Hi Siva Reddy. Thank you, Clear explanation. One Question. As HashMap allows only one null key, in the 0th element only one value will be inserted, but as per the diagram there are two values inserted with null key. please reply on this. Thanks in Advance
@SivaReddyJavaTechie8 жыл бұрын
Hi Ravi, If you insert a null key then only it will inserted at 0th element. In the diagram, the concept is when more than one key having the same hashcode then for the particular bucket(index postion), hashMap stores in the form of Entry(key-value) which internally uses LinkedList. So In the diagram, at the bucket 0th position more than one key having the same hashcode which results into both keys will represent in the same bucket and entriesl stored in the form of LinkedList. Hence same bucket index pointing to more than one key-value pair. Thanks, SivaReddy
@jaganr57258 жыл бұрын
Hai, not only null value stores in 0 position but also hash code key calculated values also comes with 0 index.like hashcode is 37520 and table size is 16 .in this scenario hascode index 0 comes has zero.
@kishoreramana17 жыл бұрын
can you please explain, how 2 or more values(V) having the same hashcode() and different equals() logic, will store in a same bucket (same index)?
@ganeshk39206 жыл бұрын
Hi Ravi, I have one query 1.why hash map accept the null as key 2.why hash table does not accept the null as key
@unconscious3693 жыл бұрын
Good explanation
@utkirsoporboev50097 жыл бұрын
Hi Siva, thank you for this video and could you tell me how to increase table[] size when it is full after 16 element put different hashcode, thanks.
@SivaReddyJavaTechie7 жыл бұрын
Rehashing increases the number of available buckets as a function of the number of entries currently stored in the HashMap.It occurs when the HashMap implementation determines the number of buckets should be increased in order to maintain the expected O(1) lookup and insertion performance.You are correct regarding the .75 default load factor and how it will cause the HashMap to be rehashed when the 13th entry is added.However, it is not correct that default capacity of HashMap 16 means it can store 16 element in it. Any bucket can store multiple entries. However, in order to preserve the desired performance, the average number of entries per bucket should be small. That's the reason we have the load factor, and the reason we should use a proper hashCode() that spreads the keys as evenly as possible across the buckets.
@macherladevasundaram49284 жыл бұрын
Well. Explained bro.. But bit confused😕..
@viplovedev7 жыл бұрын
Clearly and lucidly explained
@SivaReddyJavaTechie7 жыл бұрын
Thanks Viplove
@Ravikumar-gj6qw6 жыл бұрын
Y sir hash code of two keys are same in the figure in which case they will come
@shivasankar2487 жыл бұрын
Hi SivaReddy, Thanks for providing us very detailed explanation. I have one doubt, what happens at the time rehashing ? Is there any relation in hashcode() generation and capacity of bucket. I mean, If i create hashmap with initial capacity with 100. Is there any difference in calculating hash ? Thanks in advance !!
@SivaReddyJavaTechie7 жыл бұрын
Rehashing can be done in two cases: 1) When the present m'/n ratio increases beyond the load factor 2) M'/n ratio falls to a very low value say 0.1 In both the cases m' is the current number of entries. Also, both the cases demand the shifting of the present entries into a bigger or a smaller hash table. In the question's context rehashing is the process of applying a hash function to the entries to move them to another hash table. It is possible to use the hash function which was used earlier or use a new function altogether. Rehashing is also done when a collision occurs.
@satishrock96216 жыл бұрын
There is no concept of capacity of a bucket at all. The capacity defines the number of buckets
@prashanthponnuswamy81016 жыл бұрын
Sir how does treeset work...
@deepak1234177 жыл бұрын
Still load factor presence is not clear if load factor is not present and resizing will happening when we put 17th element, whats is the harm in it....
@satishrock96216 жыл бұрын
Load factor will be calculated when HashMap reaches it's 3/4 capacity. For example, initial capacity is 16 and load factor is 0.75 nothing but 3/4, so 16X(3/4) = 12 means when 12th element is inserted then size will be doubled.
@ManpreetSingh-ei3gc8 жыл бұрын
Hi, null value is stored in bucket 0 , that is OK. What if the first value is not null then in which bucket it will get stored?
@B-Billy7 жыл бұрын
according to calculated HASH CODE.
@shafivullar41808 жыл бұрын
When to use abstract class and interface in java.
@SivaReddyJavaTechie8 жыл бұрын
Use an abstract class when you want to define a template for a group of sub-classes , and you have at least some implementation code that call sub-classes could use.Use an interface when you want to define the role that other classes can play, regardless of where those classes are in the inheritance relation.
@shivanaikrachanaikar28437 жыл бұрын
can you please explain with example for the above explanation.
@senthilkumar-ki7fk6 жыл бұрын
pls share the source code used in this lecture... thanks in advance
@YogeshDarji997 жыл бұрын
Thanks for clear explanation. Can hashMap take 'Object' as a key? If yes, how do we retreive objects value from map?
@SivaReddyJavaTechie7 жыл бұрын
Yes, An Object can be passed as Key in HashMap. If you want to do so, you need to override equals and hashcode methods in the class to make sure that if two objects are equals using equals method, for those two objects , it should return same hashcode.
@SivaReddyJavaTechie7 жыл бұрын
I uploaded a video to explain this concept : kzbin.info/www/bejne/fp3TiKV-aKiWpa8
@YogeshDarji997 жыл бұрын
Thanks for creating a video to explain this concept.
@satishrock96216 жыл бұрын
You can you object type, not Object. You have to override hashCode() and equals methods to remove duplicates
@ggova17697 жыл бұрын
what is bucket how it works
@SivaReddyJavaTechie7 жыл бұрын
An instance of HashMap has two parameters that affect its performance: initial capacity and load factor. The capacity is the number of buckets in the hash table. Each bucket can have multiple key-value pairs. The object's hashCode() determines which bucket it goes into, via this expression: object.hashCode() % n, where n = the total number of buckets and % is the modulus operator. Most often the objects will be well distributed across buckets, but you have no guarantee where they go. This depends on the data and the hashCode function. Obviously, when the hashCode implementation is poor, the performance of the hashmap will go down. Also read up on the equals / hashcode contract, which is relevant
@durgasinghthakur6 жыл бұрын
hashmap will give only wrong key when you are you using custom(Employee) object as key because when u use string or wrapper class they have implemented hash code ,equals ,to string method they are calculation are in cache n they are faster kindly give custom object implementation thanks in advance
@SivaReddyJavaTechie6 жыл бұрын
Hi Durga, Please go through this video @ kzbin.info/www/bejne/fp3TiKV-aKiWpa8
@johnnybatafljeska63687 жыл бұрын
THANK YOU SIR!
@SivaReddyJavaTechie7 жыл бұрын
Thanks Johnny
@MayankGupta-el9rj7 жыл бұрын
Hi Siva Reddy. Thank you for nice explanation.
@SivaReddyJavaTechie7 жыл бұрын
Thanks Mayank.
@codewithneeraj937 жыл бұрын
Thanks
@akashphadtare3117 жыл бұрын
Good explanation about internal working of hash map
@SivaReddyJavaTechie6 жыл бұрын
Thanks Akash.
@Rameshm-zl2vy7 жыл бұрын
thankyou sir
@SivaReddyJavaTechie7 жыл бұрын
Thanks Ramesh.
@ibrahimshaikh36425 жыл бұрын
Nice sir
@SivaReddyJavaTechie5 жыл бұрын
Thanks Ibrahim. Please refer our KZbin channel to your friends circle as it might be helpful for them. Happy Learning.
@ibrahimshaikh36425 жыл бұрын
@@SivaReddyJavaTechie sure sir,plz make same video for LinkedHashMap and TreeMap
@SivaReddyJavaTechie5 жыл бұрын
@@ibrahimshaikh3642 .sure. will upload video on requested topic soon.
@ibrahimshaikh36425 жыл бұрын
@@SivaReddyJavaTechie hi sir, We are still waiting for LinkedHashMap and TreeMap implementation for the same, no one has created video like this before
@SivaReddyJavaTechie5 жыл бұрын
@@ibrahimshaikh3642 Mostly by end of this week, I will upload video on TreeMap internal implementation.