14.11 HashMap and HashTable in Java

Поделиться
HTML-код
  • Опубликовано: 22 янв 2025

Комментарии • 259

  • @tmzpanda
    @tmzpanda 5 лет назад +45

    3:05 HashMap, LinkedHashMap, TreeHashMap, HashTable implements Map Interface
    4:55 "keySet" method
    5:31 "Map.Entry(I) and "entrySet" method
    7:59 LinkedHashMap, TreeHashMap vs HashMap

  • @spacetime_wanderer
    @spacetime_wanderer 5 лет назад +19

    Great going sir! I tend to first search your channel for things I am looking for before looking elsewhere. Keep up the great work, sir.

  • @Affliction604
    @Affliction604 6 лет назад +56

    That's one of the best tutorials i've ever watched

  • @taruntosh7970
    @taruntosh7970 5 лет назад +4

    This is the best tutorial in entire internet. Thanks for the effort.

  • @Avaylia
    @Avaylia 5 лет назад +10

    Incredibly helpful video! Super clear and concise :)

  • @maverickmegastar
    @maverickmegastar 5 лет назад +5

    🙏
    After scanning through a ton of implementations this has to be one of the most concise video on this topic.

  • @angelguzman477
    @angelguzman477 3 года назад +1

    Navin, you look so much better now, your English has improved and you explain better, Its amazing seeing how much you have improved

    • @Sumedh_v1
      @Sumedh_v1 3 года назад +1

      It's a 5 years old video, he's now the knowledge source for crores of developers. Please mind before commenting.

  • @parshuramrathod1681
    @parshuramrathod1681 2 года назад +2

    Because of you I got placed in compan.thankyou so much

  • @ShakirAli-r7c
    @ShakirAli-r7c Год назад +1

    Lot's of thanks dear sir, Awesome videos, learning Java videos is a amazing. Perfect clarification - HashTable is synchronized and shouldn't it be a single thread instead of multiple threads.👍👍👍👍👍👍

  • @ashwiniv7053
    @ashwiniv7053 5 лет назад +8

    Awesome videos, learning Java thru ur videos is a breeze. Small clarification - HashTable is synchronized and shouldn't it be a single thread instead of multiple threads.

  • @vengateshan7800
    @vengateshan7800 Год назад

    The way of explanation is very crystal clear and understandable

  • @faixan13
    @faixan13 3 года назад +2

    We can iterate directly also on entry set rather than saving first in Set.
    for(Map.Entry i : map.entrySet()) {
    System.out.println(i.getKey()+" " + i.getValue());
    }

    • @surykaushal2140
      @surykaushal2140 2 года назад +1

      yes you can, he was just making it simpler to every one like if you have map.entrySet() then it can be assign to Set. Also we all can save variable , it was done here for readability

  • @FindARandom
    @FindARandom Год назад

    Love telusko since 2019

  • @shriramjadhav7891
    @shriramjadhav7891 2 года назад

    Thank you so much for such partical and to the point explanation.
    Thank you so much over again.

  • @ger1991mess
    @ger1991mess Год назад

    You make it look so simple!!! Thank you very much sir.

  • @nagavadlapudi
    @nagavadlapudi 5 лет назад +1

    How to print whole key set? - 4:54
    What is entry set and how to print it? - 5:31

  • @naturefriends3531
    @naturefriends3531 4 года назад +1

    Great explanation, very useful

  • @RahulPahuja1991
    @RahulPahuja1991 3 года назад

    Thank you so much for this Navin

  • @madanreddy2322
    @madanreddy2322 Год назад +2

    One thing is wrong here,in hash map multiple threads will work at a time where as in hash table only single thread at a time( you did a mistake in comparison table )

    • @talhakhan4329
      @talhakhan4329 2 месяца назад

      It is prefer to work with single thread in hashmap as it is not thread safe and if we work with multiple threads then inconsistency might occur.
      Whereas in hastable as it is synchronised u can go for multiple threads without worrying about inconsistency as it is synchronised. Jvm will take care of it, at a time only one thread will execute.

  • @alextrex3975
    @alextrex3975 6 лет назад +2

    very helpful, thank you for the effort you've put into these videos

  • @AbdulRizwan
    @AbdulRizwan 7 лет назад +1

    the way you teach is really awesome :) very nice work.

  • @mugdhashrivastava
    @mugdhashrivastava 2 года назад

    amazing explanation. thank you so much sir

  • @asifkarimbherani6386
    @asifkarimbherani6386 8 лет назад +8

    Hey when are you planning to upload the next video to this playlist? So far it was very good and helpful and we are waiting for more videos on collection playlist.

    • @shubhamjadhav4728
      @shubhamjadhav4728 10 месяцев назад

      7 years ago u were learning collections just wanna ask how's ur programming going..?

  • @iskandarzakirov230
    @iskandarzakirov230 4 года назад +1

    Very clear explanation, sir! Great Job! Like + Subscription.

  • @technical9871
    @technical9871 4 года назад

    Nice video . Thanks for very useful information

  • @setudutta3905
    @setudutta3905 5 лет назад +1

    You da best... very well explained.

  • @Karbonblade
    @Karbonblade 4 года назад +48

    "If you know the key, you will get the number". Well I got arrested instead.

  • @Naranja93
    @Naranja93 15 дней назад

    this is a great overview, thanks a lot!!

  • @mathsforiit-jee9730
    @mathsforiit-jee9730 4 года назад

    it was direct in the point .. learned quickly thnx.

    • @nithyasivaprakasam4925
      @nithyasivaprakasam4925 2 года назад

      Very clear explanation.. superb.. thank u so much sir.. ur videos are easy to understand even if it is a big thing..

  • @hermesmercuriustrismegistu4841
    @hermesmercuriustrismegistu4841 3 года назад

    Thx for the valuable information

  • @poojajoshi3174
    @poojajoshi3174 4 года назад

    finally my map concept clear thankyou sir :)

  • @rovsenhuseynov8368
    @rovsenhuseynov8368 4 года назад +1

    Amazingly informative video.

  • @gener6995
    @gener6995 5 лет назад +2

    Hi navin, good job....keep up the great work...can you please make a video on internal working of map in Java.

  • @WisdomofHal
    @WisdomofHal 4 года назад

    You are the G.O.A.T

  • @قارئة-ط4ش
    @قارئة-ط4ش 4 года назад

    very helpful,Amazing explain. thank you

  • @archerli7257
    @archerli7257 4 года назад

    Thank you! Very helpful tutorial

  • @kalppatil7568
    @kalppatil7568 Год назад

    thank u telusko sir
    --regards from an alien

  • @mahmudhr2760
    @mahmudhr2760 7 лет назад

    Excellent example to make it explained.

  • @rukikar5643
    @rukikar5643 8 лет назад

    Very good explanation. Thank you

  • @ΑντρέαςΣωτηρίου-π8γ

    you are the best man god bless you

  • @Ketrixx
    @Ketrixx 7 лет назад

    Great job as always !!!!

  • @chereddy9833
    @chereddy9833 2 года назад

    hardwork defines the sucess like the above example!!!!

  • @parikshitmadahar2329
    @parikshitmadahar2329 4 года назад

    One of the best explanation👏👏

  • @simm5622
    @simm5622 3 года назад

    Thank you 👍

  • @RahulKumar-de2rw
    @RahulKumar-de2rw 5 лет назад +4

    I've seen many tutorial of a Java but this is the best one, sir why don't u start pega software tool?? It is also based on Java,

  • @Aeizium
    @Aeizium 5 лет назад +1

    Awesome video :)

  • @nayanrajvansh6705
    @nayanrajvansh6705 5 лет назад

    At 4:04 What would be the output if we execute System.out.println(phonebook.values()).. Will it be sorted if yes then on what basis .. Please explain .Thanks in Advance

  • @hazimijaz
    @hazimijaz 4 года назад +1

    Difference between HashMap & HashTable 6:46

  • @Mr_TravelEatWorship_Official
    @Mr_TravelEatWorship_Official 5 лет назад +1

    One more Difference
    .........................................
    HashMap allows "Null Values"....whereas....HashTable doesn't allow "Null Values"....
    ............................
    One Correction
    ...........................
    .......The Methods of both Objects work with Multiple Threads......

  • @sreekanthreddy9087
    @sreekanthreddy9087 8 лет назад

    nice explanation.Thanks for information......

  • @aquabhi3773
    @aquabhi3773 5 лет назад +3

    I'm only 10 but its still very good and I can still understand, I'm trying to create a game and this tutorials has helped a lot

    • @cutevideos9571
      @cutevideos9571 5 лет назад

      Learn unity or gamemaker

    • @kuchukboromdebbarma2117
      @kuchukboromdebbarma2117 5 лет назад +1

      @@cutevideos9571 if one wants to shine in making games he has to grab programming early on, focusing on other aspects will slow him down because objects of unity deal with inheritance and objects. Learning codes should be the first thing any wanna be game Dev should start with. No only will you have knowledge about implementing your features but also step up the ladder quicker because all you need to get used to us the engine library and 3d art works and how they work. Learn coding first mate trust me.

  • @saddamahmad2310
    @saddamahmad2310 5 лет назад

    thank you very much sir for this video

  • @nancyreva5722
    @nancyreva5722 3 года назад

    Is HashMap working single thread? HashMap is unsynchronized right!.. so it's used multithreaded only, but you mention hashmap works with a single thread in the hashmap and hashtable difference.. if it is right you mentioned, please explain.

  • @shaiknagoorvali8983
    @shaiknagoorvali8983 6 лет назад

    Great tutorial sir

  • @muruganpalani2007
    @muruganpalani2007 7 лет назад

    T
    hanks boss for the simple clarifications ............

  • @Isha_Sethi
    @Isha_Sethi 3 года назад +1

    5:52 why e.setValue is used?

  • @amolgenius06
    @amolgenius06 7 лет назад +2

    in Map.entry , entry is inner class of interface map

  • @ShoeibShargo
    @ShoeibShargo 3 года назад

    Can anyone tell me, what is this sign ? Is it a paramerter or what?

  • @anikevin
    @anikevin 3 года назад

    Thank you sir

  • @prameshkumar4932
    @prameshkumar4932 3 года назад

    Naveen, How will we fetch all key and its values using old for loop ? i am trying but not able to do it with normal for loop ? could u please help..

  • @shabirafshar9773
    @shabirafshar9773 5 лет назад

    You made me understand man
    thank you SIR

  • @algorithmsguide5076
    @algorithmsguide5076 5 лет назад

    Thank you Sirji !!

  • @rajarshibasu007
    @rajarshibasu007 4 года назад

    Hello sir what is the meaning of this line please help (although it is not related to this video) : HashSet hs=new HashMap();

  • @ravindraprajapati468
    @ravindraprajapati468 6 лет назад

    this video give very good information about haaaaaaashmap

  • @kanchapaudukumbura7991
    @kanchapaudukumbura7991 4 года назад +1

    Do you have video about hashtable implementations/functions? (like your videos of linkedlists,ques,stacks)
    I

  • @showtimeGiggles
    @showtimeGiggles 12 дней назад

    great explanation!

  • @saipoojitha7553
    @saipoojitha7553 4 года назад

    Sir,the video really very helpful...I have a doubt...is it possible to map HashMap....

  • @sankalpjain63
    @sankalpjain63 5 лет назад +3

    Great video.
    Just one thing, there is no TreeHashMap in java docs instead there is TreeMap.

  • @channelkerr
    @channelkerr 4 года назад

    Is it possible to have a multiple attributes instead of just 1 key to 1 value like a CSV? eg
    Name, age, weight
    Bill, 18, 60

  • @seenu007
    @seenu007 7 лет назад

    I like your channels name...innovative!

  • @abhinavthakur6780
    @abhinavthakur6780 2 года назад

    Is there any class called TreeHashMap? I think it is TreeMap only right?

  • @RahulKumar-de2rw
    @RahulKumar-de2rw 5 лет назад

    Good one sir

  • @rezaurrahman6455
    @rezaurrahman6455 4 года назад

    super video. thank you :)

  • @The_Dadi_Divya_
    @The_Dadi_Divya_ 8 лет назад +5

    I think there is mistake in your slide u have written HashTable is Syncronised well Its true. but it should not access by multiple threads. synchronized mean only single thread can access at a single time. Please revert me if i am wrong.

    • @bikashn8641
      @bikashn8641 7 лет назад

      Yes u r absolutely correct...

    • @AshishMishra-ct9iy
      @AshishMishra-ct9iy 7 лет назад +1

      exactly!!

    • @ahalya4238
      @ahalya4238 7 лет назад +3

      when there are multiple threads in an application only we use synchronization to not to access particular block to all the threads simultaneously.so what he said is true.

    • @bikashn8641
      @bikashn8641 7 лет назад

      pls first check the point prooperly then you can understand it/....in a synchronised method we can not execute multiple threads at a time...

  • @maheshrebba2437
    @maheshrebba2437 8 лет назад

    Hashtable is synchronized then how it allows to work with multiple threads some people may ask this question so here i am clarifying the question...As per java synchronize internally lock and unlock method follows..when any single thread enters to process automatically it is surrounded by lock which wont allow other thread to process untill 1st thread process completed and lock release So it is good to use for multi-threading environment..

    • @rhimanshu6288
      @rhimanshu6288 7 лет назад

      Idiot!!...Why we use Synchronization?? That is to deal with multiple threads in synchonized way i.e to allow only ONE thread instance at a time, that's why LOCKING is intoduced to achieve that motive. So you are SAFE while dealing with MULTIPLE threads in HASHTABLE, while in HASHMAP its not safe to deal with multiple threads as there is NO locking mechanism hence will land you to some inconsitent result. I hope you understood now.
      Please verify YOUR concepts before putting -ve comments.
      Thanks

    • @maheshrebba2437
      @maheshrebba2437 7 лет назад

      Hai Idiot what are you doing from 8months ??...hahaha have you learned again hashmap and hashtable...
      Dont use low level language which i can use better than you...But your in respectable position so iam unable to do that..Plz control your words..

    • @rhimanshu6288
      @rhimanshu6288 7 лет назад

      I am very sorry dude.!! Your words itself prooved your "IDIOT"
      Yes I am again learning HashMap and HashTable but I am DAMN sure I have better understanding than you...!! As per your freaking comments after 8months too it seems you didnt have a CLEAR concept and will also not have in future for SURE...!!
      Anyways I dont want to waste time with a senseless guy like you who!!
      You can only be better in low level language..!! (As mentioned by you only).

    • @maheshrebba2437
      @maheshrebba2437 7 лет назад

      I already proved for my big clients for (India & US) government and pvt with High security webservices agile projects....Yes i'm an Idiot for short minded people...

    • @rhimanshu6288
      @rhimanshu6288 7 лет назад

      LOL!!....Not understanding HashMap and provided high security bla bla bla.....!!You can just FART around and fill the env with your freaking smell !! Dont let me rip you out again and again!!

  • @girjashankar7925
    @girjashankar7925 4 года назад

    can you please tell me,why in hashtable ,no null key is allowed?

  • @mamatanaik9699
    @mamatanaik9699 2 года назад

    what is difference between map.keySet() and map.entrySet(),at what condition to use these things

  • @hamdamboyurunov6034
    @hamdamboyurunov6034 5 лет назад

    good thanks sir

  • @shashgo
    @shashgo 7 лет назад

    if the keyset is one way of getting all the key value pairs then is there any reason to use the other way of map.entry? If the end result is to get all the key value pairs without individually knowing each key, then what is the need of the map.entry method, and why would they want to ask about that in an interview.

  • @aishwaryarokade1150
    @aishwaryarokade1150 5 лет назад

    Nice video ..could you please give an example of hashmap under hashmap

  • @jkk23-g7c
    @jkk23-g7c 4 года назад

    Can we not create an ArrayList of objects?

  • @shivjanveja2016
    @shivjanveja2016 5 лет назад +1

    Sir can you please explain the algorithm for hashing. How it works internally in the next upcoming video.

  • @techpro8565
    @techpro8565 4 года назад

    What ??? Hashtable is synchronized but uses multiple threads and HashMap is unsynchronized but uses single thread.. How is this happening.. Seems there has been a mistake...

  • @soybenh9340
    @soybenh9340 4 года назад

    Thank you for the tutorial, am using jdk 8, it doesn't support these data structures :hashtable,hashmap...what should i do?

  • @BuffaloBlack
    @BuffaloBlack 3 года назад

    Fantastic

  • @nameizdanny
    @nameizdanny 7 лет назад

    hi sir i am big fan of you,sir can you make a video on what is difference between Hashcode and equals method in collection

  • @melinatomala7831
    @melinatomala7831 8 лет назад +1

    Hi to all of you.. I have a question.. if I want to do a program to check and keep updating student data..
    something like:
    1 see data
    2 find student data
    3 exit
    for that... what do you think I have to use..hashtable or hashMap?

    • @Sushantway
      @Sushantway 6 лет назад

      If your application is multithreaded go for hashtable or use hashmap

  • @addicted09111
    @addicted09111 7 лет назад

    can we give more than one value to a single key ? any method to do that ?

  • @soham_bhattacharya
    @soham_bhattacharya 4 года назад

    Sir, suppose I want to sort String keys according to its length, how do I do it!

    • @nitin8692
      @nitin8692 4 года назад

      private static void mapKeSortByLength() {
      Map testMap = new HashMap();
      testMap.put("aaa", "333");
      testMap.put("aaaaa", "55555");
      testMap.put("aaaa", "4444");
      testMap.put("aa", "22");
      testMap.put("a", "1");

      Set allKeys= testMap.keySet();

      List listKeys = new ArrayList();
      for(String k : allKeys) {
      listKeys.add(k);
      }

      Collections.sort(listKeys, Comparator.comparing(String::length));

      System.out.println(listKeys);

      }

  • @maweryoutube9852
    @maweryoutube9852 5 лет назад +1

    YOU ARE AMAZING AS ALWAYS ^_^

  • @AbhishekGupta-ji4pf
    @AbhishekGupta-ji4pf 3 года назад +1

    some people must love when sir calls us aliens, i guess

  • @soumitramehrotra5547
    @soumitramehrotra5547 7 лет назад

    sir,is there any way to input the entries at once into a hashmap rather than using put() function for very entry ?Also is there any way to see a particular value, and not all the value in the map.

  • @navinmarcos
    @navinmarcos 8 лет назад +32

    There's nothing called Treehashmap, it's just tree map.

    • @MyThoughts7t
      @MyThoughts7t 7 лет назад +1

      Even you got little confused while reading TreeMap----Hash----TreeHashMap, may be someone in your team would has prepared the visuals.

    • @shabir301
      @shabir301 5 лет назад +1

      @@Telusko why we didn't gona use array class that contains two string to store name and contact it so easy as compare to hash map .....And flexible

    • @jvsnyc
      @jvsnyc 4 года назад

      @@shabir301 If you only have 3 or 4 friends that works fine. If you are looking up thousands of numbers per minute out of millions and millions and millions of possible choices, HashMap will still be blazingly fast, and you will drag a whole CPU down if you try to do that with an array.

  • @mamidivarun1100
    @mamidivarun1100 7 лет назад

    hello sir i have a doubt
    hashmap is not threadsafe so it is faster than hashtable
    but you mention hashmap works with only one thread
    by using only single thread how we can get faster performance.
    please explain me

    • @aayushdeo9143
      @aayushdeo9143 3 года назад

      Sir said if you're working with only one thread then go for HashMap, otherwise go for Hashtable.

  • @suhasnayak4704
    @suhasnayak4704 5 лет назад

    Say, there is a bucket X and its capacity has reached TREEIFY_THRESHOLD i.e., 8, but MIN_TREEFIY_CAPACITY is not yet reached, say MIN_TREEFIY_CAPACITY is still 16. Then the Linked List structure in bucket X will not be converted to Balanced Binary Tree as MIN_TREEFIY_CAPACITY is not yet reached. Instead number of buckets is doubled. So now, our MIN_TREEFIY_CAPACITY becomes 16+16=32. Say now we again try to add a value to hashmap which hash's to bucket X, then will the bucket X continue to store the values in a Linked List fashion as MIN_TREEFIY_CAPACITY is still not reached ?

  • @asrarahmed1629
    @asrarahmed1629 3 месяца назад

    Thanks

  • @TheRealSatyaVarma
    @TheRealSatyaVarma 8 лет назад

    thank u so much

  • @unknownuser-wr3zm
    @unknownuser-wr3zm 3 года назад

    🙏 tq sir

  • @MsWonderlands
    @MsWonderlands 6 лет назад

    so...for storing key-value pairs, we could very well use Arrays, by storing keys as indices and values as the Array Values. What is so specific about HashMaps?

  • @AravintakshanarunagiriRA
    @AravintakshanarunagiriRA 4 года назад

    thank u da mota thala