How HashMap Internally Works in Java With Animation | Popular Java Interview QA | Java Techie

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 171

  • @NamChics
    @NamChics 10 หลายเดือนก่อน +11

    I have seen many videos on this topic but no one explained this topic as simpler and easy as you explained...thank you so much bhagwaan apki har muraad puri kare

  • @rohitkhandelwal313
    @rohitkhandelwal313 2 ปีที่แล้ว +18

    I saw more than 50 videos on hashing , but this was the one which made me actually understand, thankyou sir.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks Rohit. Keep learning 😃

    • @PIYUSH-lz1zq
      @PIYUSH-lz1zq ปีที่แล้ว

      bro , if there kar 2 null key then second value will be placed in ??

    • @rohitkhandelwal313
      @rohitkhandelwal313 ปีที่แล้ว

      @@PIYUSH-lz1zq I think 0th bucket

    • @rohitkhandelwal313
      @rohitkhandelwal313 ปีที่แล้ว

      @@Javatechie am I right?

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Yes correct

  • @poojababar8746
    @poojababar8746 4 หลายเดือนก่อน +2

    Sidhi bat no bakwas vala explanation, straight, simple , good work sir

  • @subhamsharma8268
    @subhamsharma8268 2 ปีที่แล้ว +8

    That is a very simplified and a splendid explaination of hashmap. Thank you so much sir.❤

  • @priyankashaw1238
    @priyankashaw1238 ปีที่แล้ว +5

    Your explanation is to the point and very clear. Request you to also add how hashmap retrieval works when there is more than 1 key in the same bucket.

  • @girishrp9339
    @girishrp9339 2 ปีที่แล้ว +1

    In youtube have more than 1000+ videos same question but your video is very easy to understand.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @gandamraviteja7019
    @gandamraviteja7019 2 หลายเดือนก่อน +1

    Great thank you so much just less than 10 mins you cleared lot of things
    even thanks feels tiny for ur work

  • @varmamayank
    @varmamayank 18 วันที่ผ่านมา +1

    Extremely simplified explanation !!

  • @PraveenKumarpksksit
    @PraveenKumarpksksit 8 หลายเดือนก่อน

    Thankyou for so much detailed and simplified way of teaching HashMap. It is really helpful for anyone who wants to either learn fresh or just wants to revise again. Really Appreciate !!

  • @maankhurana5814
    @maankhurana5814 9 หลายเดือนก่อน +2

    Awesome watched 10 more videos on youtube before this .... not able tp understand concept... but u made it very simple ... Thanks alot

  • @manamohansamal1040
    @manamohansamal1040 2 ปีที่แล้ว +11

    Brother your explanation helps to easily understand the topic. ❤️❤️ One request if you can make a video one interview questions with different types of url mapping to the dispatcher servlet like /,/*,/** etc . It will be very helpful 🙏🙏

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +2

      Okay I will do that. This is kind of URL patterns

  • @pateldharmesh1361
    @pateldharmesh1361 10 หลายเดือนก่อน +1

    Bhai your tutorial clears all doubts most of the time

  • @acchutdevkule7841
    @acchutdevkule7841 2 ปีที่แล้ว +2

    You are one of the underrated tech youtuber ...

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      Thanks buddy 🙂 for your word . Will hope to grow soon .

  • @prajwalbandekar3557
    @prajwalbandekar3557 11 หลายเดือนก่อน +1

    The BEST easy explanation out there, Thank you Sir 🤝

  • @charangowda384
    @charangowda384 ปีที่แล้ว +1

    Bro I have seen a lot of videos , but this is by far the best explanation video i have seen on youtube clean, simple and clear.

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Thanks buddy 😊. Glad to hear this ☺️

  • @trendingthoughts6726
    @trendingthoughts6726 17 วันที่ผ่านมา +1

    Super understandable videos..keep doing❤❤❤

  • @subramanianchenniappan4059
    @subramanianchenniappan4059 ปีที่แล้ว +1

    thanks bro. useful for interviews. i am a java backend restful API project tech lead. will apply for job

  • @AayushGore-
    @AayushGore- หลายเดือนก่อน +1

    When i thought of this q i thought of receiving answer from java techie. I search on TH-cam and first video your name came 😂

  • @pranavjog172
    @pranavjog172 10 หลายเดือนก่อน +2

    Hi, Could you please make a video on HashMap internal working in Java 8 or new addition in Java8 for HashMap?

  • @sameerkadgaye2048
    @sameerkadgaye2048 2 ปีที่แล้ว +2

    Very clear explanation thank you sir

  • @raghugupta8959
    @raghugupta8959 2 ปีที่แล้ว +1

    i understand very clear,thanks for explaining neatly🙂🙂

  • @NamChics
    @NamChics 10 หลายเดือนก่อน +2

    I am subscribing your channel just because of this video

    • @Javatechie
      @Javatechie  10 หลายเดือนก่อน

      Keep learning 👍 I believe you like other videos as well

  • @ranjithkumarravichandiran8983
    @ranjithkumarravichandiran8983 ปีที่แล้ว +1

    Thank you so much for clear explanation.👏👏

  • @naveenkumardasari
    @naveenkumardasari 8 หลายเดือนก่อน +1

    It would be more helpful, if you explained about retrieving elements from hashmap.

    • @Javatechie
      @Javatechie  7 หลายเดือนก่อน

      Will do another video

  • @priyay
    @priyay ปีที่แล้ว +1

    Simple and clear thankyou

  • @maheshrevaskar7658
    @maheshrevaskar7658 ปีที่แล้ว +1

    Thanks Basant! Video on working on ConcurrentHashMap will be helpful. Saw many videos, but still its not clear.

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Sure i will do that

  • @sathishkumarr7106
    @sathishkumarr7106 หลายเดือนก่อน

    Thanks bro. It's really helpful for me to understand easily

  • @sergiogb
    @sergiogb 2 ปีที่แล้ว +2

    Thanks, good an easy to understand

  • @forouzannaderi-vw3sp
    @forouzannaderi-vw3sp 4 หลายเดือนก่อน +1

    great explanation thank you so much 😍👏

  • @supun_sandaruwan
    @supun_sandaruwan 9 หลายเดือนก่อน

    All In one video Thank you sir 💖

  • @FacundoMartín-z2r
    @FacundoMartín-z2r 11 หลายเดือนก่อน +1

    Thank you so much for this explanation! It's really clear with the examples you did :D

  • @pravin.a.mahajan
    @pravin.a.mahajan 4 หลายเดือนก่อน +1

    Hi Basant, Recently I got one question from interview that, will it create bucket of 16 when you create map instance? I did debug the code and found that it creates bucket when you first element into map. your explaination at 1:00

    • @Javatechie
      @Javatechie  4 หลายเดือนก่อน +1

      That's correct but will cross validate and update you

  • @nagireddy1507
    @nagireddy1507 2 ปีที่แล้ว +1

    very clear explanation... Thank you

  • @chetanbhandari3033
    @chetanbhandari3033 2 ปีที่แล้ว +1

    Awesome explanation waiting more interviews questions videos

  • @muralitreddy
    @muralitreddy 2 ปีที่แล้ว +2

    Simple and neat explain

  • @MaheshAnand1995
    @MaheshAnand1995 2 ปีที่แล้ว +2

    Should have been more helpful if you explained the get process as well. Thank you

  • @amscoder5262
    @amscoder5262 2 ปีที่แล้ว +2

    Simply awesome explanation brother 👌👌👌

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks brother 🤗

  • @Satenc0
    @Satenc0 2 ปีที่แล้ว +5

    Very good explanation sir overall, but I have one little question about the hash collision, at min 5:38 you say that it first uses double equals (==) to check if they have the same hashcode, which means to check if they have the same reference right, if they result to have the same hashcode then it will just replace, but if they dont, then it will check if they have the same value (content) with .equals() method (key1.equals(key2)) right, if it is true then replace, if not then add the next node, is this well understood? please correct me if not

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +2

      Yes your understanding is correct

  • @vivekkumar-iy7zk
    @vivekkumar-iy7zk 8 หลายเดือนก่อน +1

    Thanks you explained so well

  • @rajraj8065
    @rajraj8065 2 ปีที่แล้ว +1

    Awesome explained, keep making such a good vedio .

  • @pirate1239
    @pirate1239 ปีที่แล้ว +1

    best explanation. easy one

  • @kirane5911
    @kirane5911 ปีที่แล้ว +1

    Very good explanation

  • @ShivaKumarSatakuri
    @ShivaKumarSatakuri หลายเดือนก่อน +1

    Can you explain data retrieval for the same example?

  • @raghavagarwal6545
    @raghavagarwal6545 ปีที่แล้ว +1

    Simple awesome explanation👍

  • @tolgacelikart
    @tolgacelikart 4 หลายเดือนก่อน

    great explanation , and thanks for sharıng. Just little feedback maybe :) same pronunciation was distracting me time to time on focusing, such as zero (sounds g..), hash (has), etc.
    also some of saying 'ok , fine, right, after explaning something etc ' .

  • @natureParadise777
    @natureParadise777 2 ปีที่แล้ว +2

    Like your videos, you explain the topic in very beautiful way, please make more videos on the interview questions...

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @zuggrr
    @zuggrr ปีที่แล้ว +2

    thank you soooo muchh ! you are the best

  • @vinaypandey4752
    @vinaypandey4752 2 ปีที่แล้ว +1

    Awesome explination

  • @murugeshk14
    @murugeshk14 ปีที่แล้ว

    Thank u it's was short and simple 🙌

  • @adityavyas6603
    @adityavyas6603 2 ปีที่แล้ว +2

    Very nice explanation Basant... One question if we change the content of employee object after adding as key in map then what happened..
    And in case of immutable employee class what is the behavior of map.
    Thanks in advance..

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      If you will do get (key) you will get NPE

  • @rohitchanda8461
    @rohitchanda8461 2 หลายเดือนก่อน +1

    I love this channel's content

    • @Javatechie
      @Javatechie  2 หลายเดือนก่อน +1

      Thanks buddy but BTW what is

    • @rohitchanda8461
      @rohitchanda8461 2 หลายเดือนก่อน +1

      @@Javatechie haha, no, it’s ❤️ thanks for the content!

  • @devopsshiv3842
    @devopsshiv3842 ปีที่แล้ว +1

    Yes, i got the internal hashing collision part

  • @RaviShankar-xy6zh
    @RaviShankar-xy6zh 2 ปีที่แล้ว +2

    Bro you always bring great and interesting videos in eloquent way.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @basitali9651
    @basitali9651 2 ปีที่แล้ว +1

    Thanks for this info..God job sir

  • @bhargavarajuthirumalasetty
    @bhargavarajuthirumalasetty ปีที่แล้ว +1

    this is simplified. thank ..

  • @ramyasruthi5372
    @ramyasruthi5372 6 หลายเดือนก่อน +1

    Thank you!!! Very detailed

  • @AbhijitDixit-ki1oo
    @AbhijitDixit-ki1oo 8 หลายเดือนก่อน +1

    Thank you so much sir 🙏

  • @mohammedajazquadri7869
    @mohammedajazquadri7869 2 ปีที่แล้ว +1

    brilliant explanation

  • @ungalanbuselva
    @ungalanbuselva 2 ปีที่แล้ว +1

    Great explanation

  • @PoudelP
    @PoudelP 9 หลายเดือนก่อน

    5:03
    Correct me if I am wrong but if (e1,"Dev") & (e3,"UI") both coincidentally have the same hash value, then wouldn't the hash value for second linked list at 6 be 1011, just like the linked list above it?

  • @Nikhil-jf7lv
    @Nikhil-jf7lv 7 หลายเดือนก่อน

    Welcome to java tikki ❤

  • @raajaakowsalya2711
    @raajaakowsalya2711 2 ปีที่แล้ว +2

    Hey!!! Seriously well explained 😀❤️✨✨

  • @kishorep5572
    @kishorep5572 2 ปีที่แล้ว +1

    Guys, what is the out of it?
    Map map = new HashMap();
    map.put("a", "B");
    map.put("a", "C");
    map.put(null, "C");
    map.put(null, "C");
    map.put(null, "A");
    System.out.println(map);

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      Output will be a, C and null , A

  • @pradeepnayak1988
    @pradeepnayak1988 2 ปีที่แล้ว +1

    Great Work Basant. Keep Growing.

  • @simplyarranged
    @simplyarranged 2 ปีที่แล้ว +1

    Thanks sir🎉

  • @ranachan5555
    @ranachan5555 5 หลายเดือนก่อน +1

    I am not finding you concurrent Hashmap in your list, Please send the link

  • @mohammedajazquadri7869
    @mohammedajazquadri7869 2 ปีที่แล้ว +1

    Sir please make videos on design patterns it is mostly Asking now a days in interview

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Okay buddy I will

  • @praveens2272
    @praveens2272 2 ปีที่แล้ว +2

    Nice explanation

  • @pratishrutipanda6461
    @pratishrutipanda6461 2 ปีที่แล้ว +2

    You nailed it 🔥🔥🔥

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks Pratishruti 🙂

  • @vasuimandi5535
    @vasuimandi5535 2 ปีที่แล้ว +1

    Bro, can you make a video on mock interviews or can you make video on all common interview questions in Java, So that will be helpful to those who wants to change company....

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      Hi vasu , please check below link it's already there for core java
      th-cam.com/video/fFnuer3AD8Q/w-d-xo.html

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      Part 2 : th-cam.com/video/GO67C7V-IbQ/w-d-xo.html

    • @initToLearn
      @initToLearn 2 ปีที่แล้ว

      @@Javatechie Thanks

  • @mintybreez
    @mintybreez 2 ปีที่แล้ว +1

    Very well explained 👏

  • @TanishKumar-uz4wk
    @TanishKumar-uz4wk ปีที่แล้ว +1

    Great !!!

  • @shubhammahindru3563
    @shubhammahindru3563 2 ปีที่แล้ว +1

    Hi,
    why is the size is still one ?
    Car car = new Car("Seletos",2020);
    Map carMap = new HashMap();
    carMap.put(car,"1");
    carMap.put(car,"2");
    System.out.println(carMap.size());
    In car class, I have the following implementation of the equals and hashcode ?
    @Override
    public boolean equals(Object o) {
    return false;
    }
    @Override
    public int hashCode() {
    return 1;
    }
    car.equals(car) will give it false and it should have added it as the next node but its giving the size as 1 and only node its adding ?
    I am confused in this please help, if u got some time.
    is it ? if the keys are same then it first checks == if not then only it goes for equals comparison ?

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว +1

      In both the case hashcode will be 1 only right which is again duplicate

    • @shubhammahindru3563
      @shubhammahindru3563 2 ปีที่แล้ว

      @@Javatechie Yes 1 but it should go and check for equals method which would return false(because of overridden method) and would add the value as next node ?
      So it means for duplicate keys equals method is also not checked it simply replaces the value ?

  • @sivakrishna2544
    @sivakrishna2544 8 หลายเดือนก่อน +1

    Hi bro can you make one vidow difference between 1.7 and 1.8 difference in HashMap internal architecture

    • @Javatechie
      @Javatechie  8 หลายเดือนก่อน

      Sure will do that

    • @sivakrishna2544
      @sivakrishna2544 8 หลายเดือนก่อน +1

      Thanks a lot bro❤

  • @vinaypandey4752
    @vinaypandey4752 2 ปีที่แล้ว

    Sir, what will happen, if a duplicate value is given to add, will it will check for duplicate value? Suppose if we have same value in index 1 and same value is send again to add on index 3, it will add or it will not add it?

  • @soumyaranjan6196
    @soumyaranjan6196 2 ปีที่แล้ว +1

    Awesome explanation bro 😊

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks Soumya 😊

  • @mlevidigeri
    @mlevidigeri 2 ปีที่แล้ว +1

    You’re videos very helpful. Can you please do a video on java events

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Java or spring events ?

    • @mlevidigeri
      @mlevidigeri 2 ปีที่แล้ว +1

      @@Javatechie spring events

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Okay I will do that

  • @scoobydooby4672
    @scoobydooby4672 ปีที่แล้ว +1

    Nice thanks

  • @Hamza-Shreef
    @Hamza-Shreef ปีที่แล้ว +1

    5:47
    I think if it finds the same reference or the same value it will throw an exception right ?
    and there is no replacement happening there.

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      No it won't throw any exception just debug and see

    • @Hamza-Shreef
      @Hamza-Shreef ปีที่แล้ว +1

      @@Javatechie Yes i mean i'm sorry i'm a c# developer and we have a dictionary instead of hash map but i thought they were the same .
      thank you for pointing that out to me ❤❤

    • @PIYUSH-lz1zq
      @PIYUSH-lz1zq ปีที่แล้ว

      bro , if there kar 2 null key then second value will be placed in ??

  • @vipintekade6400
    @vipintekade6400 ปีที่แล้ว +1

    Lovely .

  • @jagadeeshbelagallu5243
    @jagadeeshbelagallu5243 2 ปีที่แล้ว

    If put Method find same content what will happen? is it throw error or ignoring to store the content into that object?
    If e1.equals(e3 is it override e3 content?

  • @Akhilesh_Reddy
    @Akhilesh_Reddy 2 ปีที่แล้ว +1

    Good one Basant.

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks buddy 😊

  • @learnprogramming6930
    @learnprogramming6930 2 ปีที่แล้ว +1

    Thank you

  • @VishalSharma-rn7mt
    @VishalSharma-rn7mt 11 หลายเดือนก่อน +1

    Awesome

  • @rohitsharma-xt8qe
    @rohitsharma-xt8qe 3 หลายเดือนก่อน

    5:38 here you said Map first internally used == operator to check the reference and if it is different then it will use equals method. But in the last diagram you haven't showed this ?

  • @PIYUSH-lz1zq
    @PIYUSH-lz1zq ปีที่แล้ว +1

    bro , if there kar 2 null key then second value will be placed in ??

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Yes

    • @murugeshk14
      @murugeshk14 ปีที่แล้ว

      If u first put(null, 8); its stored in the 0 th index and if again u try to put(null, 9);
      Then that first entry get replaced by this new entry in the same 0th index as in hashmap duplicate keys are not allowed, if u try to add entry with same key it's gets override

  • @sudheergundubogula
    @sudheergundubogula 2 ปีที่แล้ว +1

    Thank you so much ❤️

  • @priyanaik4099
    @priyanaik4099 2 ปีที่แล้ว

    Awesome explanation. Thank you. Can you make video for springboot?

  • @sivarama8116
    @sivarama8116 2 ปีที่แล้ว +1

    Tx sir

  • @codecompany7114
    @codecompany7114 2 ปีที่แล้ว

    ok good,
    but what is the importance of Next then?

  • @NSINGHK
    @NSINGHK ปีที่แล้ว +1

    It doesn't have linkedlist, it uses resizable array thsts why it fetch in O(1) time, if its linkedList it will fetch map.get(key) in O(n) which is wrong

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Hello buddy,
      It depends on many things. It's usually O(1), with a decent hash which itself is constant time... but you could have a hash which takes a long time to compute, and if there are multiple items in the hash map which return the same hash code, get will have to iterate over them calling equals on each of them to find a match.
      In the worst case, a HashMap has an O(n) lookup due to walking through all entries in the same hash bucket (e.g. if they all have the same hash code). Fortunately, that worst case scenario doesn't come up very often in real life, in my experience. So no, O(1) certainly isn't guaranteed - but it's usually what you should assume when considering which algorithms and data structures to use.
      In JDK 8, HashMap has been tweaked so that if keys can be compared for ordering, then any densely-populated bucket is implemented as a tree, so that even if there are lots of entries with the same hash code, the complexity is O(log n). That can cause issues if you have a key type where equality and ordering are different, of course.
      And yes, if you don't have enough memory for the hash map, you'll be in trouble... but that's going to be true whatever data structure you use.

  • @zsoltgeza
    @zsoltgeza ปีที่แล้ว

    You should create captions, because they cannot be created automatically under Your video

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Didn't get you buddy

    • @sivabalarasup7556
      @sivabalarasup7556 ปีที่แล้ว +1

      I think, he is referring to Subtitles. You could add subtitles.

    • @zsoltgeza
      @zsoltgeza ปีที่แล้ว +1

      @@sivabalarasup7556 thats right

  • @itsnarahari
    @itsnarahari 2 ปีที่แล้ว +2

    Bro in which company ur working on ?

  • @1stnamelastname24
    @1stnamelastname24 ปีที่แล้ว

    If "key" is null then it will placed at 0th bucket then what if "Value" is also null ?

  • @aloktiwari4188
    @aloktiwari4188 2 ปีที่แล้ว

    Hi sir please make video with Java 17 example

  • @shiva5600
    @shiva5600 2 ปีที่แล้ว +1

    Thanks

    • @Javatechie
      @Javatechie  2 ปีที่แล้ว

      Thanks Shiva 😊

  • @snehakarosiya2618
    @snehakarosiya2618 6 หลายเดือนก่อน

    thank you so muchh !!

  • @saudsiddiqui5698
    @saudsiddiqui5698 2 ปีที่แล้ว

    How to access the entry having null key? like map.get("?");

  • @RN-jo8zt
    @RN-jo8zt 2 ปีที่แล้ว

    what if two duplicatre was there in put() .you missed this VVVV.important concept

    • @vandanac2244
      @vandanac2244 ปีที่แล้ว

      If key is duplicate it will be overriden

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Yes

  • @leandromarcelo2340
    @leandromarcelo2340 ปีที่แล้ว +1

    could you activate the subtitles? pls

    • @Javatechie
      @Javatechie  ปีที่แล้ว

      Please click on CC while watching video. I already enabled it buddy 😊