14.11 HashMap and HashTable in Java

Поделиться
HTML-код
  • Опубликовано: 17 апр 2016
  • Check out our courses:
    Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : bit.ly/java-spring-cloud
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusko.com/
    Instagram : / navinreddyofficial
    Linkedin : / navinreddy20
    TELUSKO Android App : bit.ly/TeluskoApp
    Discord : / discord
    Complete Java Tutorial : goo.gl/3NaAW1
    HashMap and HashTable both implements Map interface.
    HashTable is synchronized and HashMap is not synchronized.
    HashMap is faster than HashTable.
    HashMap, LinkedHashMap, TreeHashMap, HashTable implements Map Interface
    Recommend Books :
    1. Head First Java : amzn.to/2owFrf0
    2. Java Complete Reference : amzn.to/2osY04k
    Java and Spring Framework For beginners with Spring Boot : - bit.ly/3LDMj8D
    Java Tutorial for Beginners (2023) :- bit.ly/3yARVbN
    Editing Monitors :
    amzn.to/2RfKWgL
    amzn.to/2Q665JW
    amzn.to/2OUP21a.
    Editing Laptop :
    ASUS ROG Strix - (new version) amzn.to/2RhumwO
    Camera : amzn.to/2OR56AV
    lens : amzn.to/2JihtQo
    Mics
    amzn.to/2RlIe9F
    amzn.to/2yDkx5F
    Subscribe to our other channel:
    Navin Reddy : / @navinreddy
    Telusko Hindi :
    / @teluskohindi
    Subscribe to the channel and learn Programming in easy way.
    Java Tutorial for Beginners : goo.gl/p10QfB
    Scala Tutorials for Java Developers : goo.gl/8H1aE5
    C Tutorial Playlist : goo.gl/8v92pu
    Android Tutorial for Beginners Playlist : goo.gl/MzlIUJ
    XML Tutorial : goo.gl/Eo79do
    Design Patterns in Java : goo.gl/Kd2MWE
    Socket Programming in Java : goo.gl/jlMEbg
    Spring MVC Tutorial : goo.gl/9ubbG2
    OpenShift Tutorial for Beginners : goo.gl/s58BQH
    Spring Framework with Maven : goo.gl/MaEluO
    Sql Tutorial for Beginners : goo.gl/x3PrTg
    String Handling in Java : goo.gl/zUdPwa
    Array in Java : goo.gl/uXTaUy
    Java Servlet : goo.gl/R5nHp8
    Exception Handling in Java : goo.gl/N4NbAW

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

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

    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.

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

    Incredibly helpful video! Super clear and concise :)

  • @tmzpanda
    @tmzpanda 4 года назад +43

    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

  • @Affliction604
    @Affliction604 5 лет назад +54

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

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

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

  • @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.

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

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

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

    Great job as always !!!!

  • @taruntosh7970
    @taruntosh7970 4 года назад +3

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

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

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

  • @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.

  • @asifkarimbherani6386
    @asifkarimbherani6386 7 лет назад +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 4 месяца назад

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

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

    You da best... very well explained.

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

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

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

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

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

    You made me understand man
    thank you SIR

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

    Very good explanation. Thank you

  • @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.

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

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

  • @user-lb1fl7sh8m
    @user-lb1fl7sh8m 7 лет назад

    you are the best man god bless you

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

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

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

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

  • @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 2 года назад +1

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

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

    Thank you Sirji !!

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

    Awesome video :)

  • @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

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

    Amazingly informative video.

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

    Excellent example to make it explained.

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

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

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

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

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

    Thank you! Very helpful tutorial

  • @user-sy1xb4uq3q
    @user-sy1xb4uq3q 4 года назад

    very helpful,Amazing explain. 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,

  • @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.

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

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

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

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

  • @madanreddy2322
    @madanreddy2322 11 месяцев назад +1

    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 )

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

    this video give very good information about haaaaaaashmap

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

    in your phone book example if i want to have duplicate name then what should be the right way to implement key value pair?

    • @samk8806
      @samk8806 6 лет назад +1

      Duplicate keys are not allowed

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

    Thanks for information. What if we have more than two columns in excel, how to store such values?

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

    thank you very much sir for this video

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

    Great explanation, very useful

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

    Great tutorial sir

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

    finally my map concept clear thankyou sir :)

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

    Thank you so much for this Navin

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

    Love telusko since 2019

  • @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

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

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

  • @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?

  • @vengateshan7800
    @vengateshan7800 9 месяцев назад

    The way of explanation is very crystal clear and understandable

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

    Nice, how to get the length of value of a perticuler key?

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

    amazing explanation. thank you so much sir

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

    thank you.

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

    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..

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

    today I learned a new concept

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

    I like your channels name...innovative!

  • @user-xd1pv6ze6x
    @user-xd1pv6ze6x 7 месяцев назад +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.👍👍👍👍👍👍

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

    thank u so much

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

    you have some tutorials regarding concurrent collections

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

    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

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

    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

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

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

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

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

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

    Thx for the valuable information

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

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

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

    super video. thank you :)

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

    Hello. Thanks for the awesome tutos. Is there a difference between: Entry and Map.Entry?

  • @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();

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

    Nice video . Thanks for very useful information

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

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

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

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

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

    Thank you 👍

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

    Whatever you have explained that is perfectly fine but I have another doubt which is related to memory leak. When we don't implement the equals and hashcode then it takes from object class in that case too it gives us some unique code, So how GC is unable to clean up those unused objects when "get" method called internally then it definitely returns its hashcode and that is a expected case. But this whole scenario is a memory leak problem so please explain this.

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

    hello sir, I have a small doubt which is asked by my friend.how can we create an object of HashSet with the help of object of ArrayList. please give me the correct solution.

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

    ConcurrentHashmap
    ?

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

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

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

    what is the use of e.setvalue("III")

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

    YOU ARE AMAZING AS ALWAYS ^_^

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

    Good one sir

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

    good thanks sir

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

    Fantastic

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

    Hi, Ive got this assement for the college:
    I have to implement a system for viewing and updating of student data. This data is giving by a .txt,
    for example:
    201504123|Carla Arias|IN-TEL|20|10|2|6.8
    201402947|Paul Zambrano|IN-TLM|21|18|0|8.1
    201508364||||||
    201502342|Ivan Torres|IN-CC-ST|19|6|0|7.5
    201201723||||||,
    my question is:
    Which method is better to implement this, hashmap or hashtable?

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

    I have one problem how to add 2 friend have same name but in Java we cannot use one key two time then how to implement the phone book in Java we use two value at a time but not key

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

    Thank you sir

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

    Its was tough to understand especially entry,but though thank u

  • @kalppatil7568
    @kalppatil7568 7 месяцев назад

    thank u telusko sir
    --regards from an alien

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

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

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

    Hello sir do you have video on arraylist?

  • @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..

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

    Tq sir..

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

    help me alot to clear concept thank you
    \

  • @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 4 года назад +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.

  • @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......

  • @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 5 лет назад

      If your application is multithreaded go for hashtable or use hashmap

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

    Wonderful

  • @sohambhattacharya6510
    @sohambhattacharya6510 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);

      }

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

    Difference between HashMap & HashTable 6:46

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

    could you pls explain how to add list into hashmap !!!! and as well as how to add the hashmap inside the hashmap???

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

    can you plz send me the link of the next practicle video

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

    thank u da mota thala