Set and HashSet in Java - Full Tutorial

Поділитися
Вставка
  • Опубліковано 17 гру 2024

КОМЕНТАРІ • 382

  • @CodingWithJohn
    @CodingWithJohn  2 роки тому +34

    Thanks to Mailgun for sponsoring this video! Head to mailgun.com/john to try Mailgun free today.
    Let me know if you have questions, or ideas for another video!

    • @praveenrock3417
      @praveenrock3417 2 роки тому +3

      You have to have way more subscribers for the quality of content you're putting out. Crystal clear presentation of concepts..

    • @CodingWithJohn
      @CodingWithJohn  2 роки тому +9

      I'll have to start making worse videos till I get more subs!

    • @kcrowe8583
      @kcrowe8583 2 роки тому

      What are your thoughts on using var for local variables? Example: var myCat = new Cat();

    • @wellingtondefassio4435
      @wellingtondefassio4435 Рік тому

      Hey John, i am missing new videos!!❤️

    • @CodingWithJohn
      @CodingWithJohn  Рік тому +1

      Sorry! I had a minor surgery that I'm recovering from at the moment so I've been delayed. But don't worry, I haven't gone anywhere, so once I'm doing better I'll be back at it.

  • @xbz24
    @xbz24 2 роки тому +58

    The fact u used breaking bad char names made u the goat,thanks for this John

  • @evelinechaza6786
    @evelinechaza6786 2 роки тому +398

    Not all heroes wear capes. John is out here saving grades.

    • @tarunsoni6971
      @tarunsoni6971 Рік тому +6

      Not all heroes wear a cape, John out here is making DSA a piece of cake.

    • @pradeepyadravi2533
      @pradeepyadravi2533 Рік тому +4

      Not all heroes wear capes. John is out here helping crack interviews

    • @poppincena5909
      @poppincena5909 Рік тому

      Joh out here helping me not get fired from my job 🥲😝 Thanks john !!

    • @DucNguyen-sd4mn
      @DucNguyen-sd4mn Рік тому

      Not all heroes wear capes. John is out here helping me crack Google Cloud system

    • @zfazzershroudvietcynide64e58
      @zfazzershroudvietcynide64e58 5 місяців тому

      this is so true

  • @juanjaimeszuluaga
    @juanjaimeszuluaga 2 роки тому +47

    Hi John! I'm a student of systems engineering. I'm from Colombia and your videos are making me improve in this language. Thank you!

  • @galdamez3
    @galdamez3 Рік тому +5

    I had to learn Java for a new job last year and while many of the concepts like Hash Sets have one-to-one parallels in other languages I’ve used, I’ve yet to read up on how to implement them in Java. This tutorial easily saved me a couple of hours of textbook reading. Keep up the great content.

  • @ГульхаёМусурмонова

    In my opinion, John is the best programming mentor on UA-cam platform! Thank you so much, John!

  • @CoffeeDev749
    @CoffeeDev749 Рік тому +31

    Thank you, John! Also, I loved the Breaking Bad characters being incorporated into the lesson.

    • @galdamez3
      @galdamez3 Рік тому +1

      Woh, I did not make the connection to the show and the sample names. I was too focused on understanding the concepts. Good eye!

  • @anubratsahoo1351
    @anubratsahoo1351 Рік тому +1

    What i couldn't understand from 1 hour long lectures,this guy just taught me under 30 mins hatss offf

  • @socaljusticewarrior558
    @socaljusticewarrior558 Рік тому +26

    Another high-quality video, John. It actually came at the perfect time for me. I was making a whole lot of spaghetti code with ArrayLists and for loops, but then I realized that I need to focus on learning data structures for a while. This very lesson just happened to be applicable to a project I'm working on right now. I'm messing with an API that gives me random cat facts, and I've been getting a lot of duplicates.

  • @telerobotic
    @telerobotic 2 роки тому +3

    It’s amazing having access to Java tutorials with the same quality and enthusiasm other YT channels give to the likes of Rust or the latest JavaScript framework. Thank you John!

  • @Firestar311MinecraftMore
    @Firestar311MinecraftMore Рік тому +1

    Hello John! While I am an experienced Java Developer, I like watching other videos and tutorials to see what is either new, or if I missed anything as I am self-taught (Or just for fun because it is entertaining and informative like your videos) and around 6:29 when you were talking about ordering being maintained is somewhat untrue
    ArrayLists do not maintain order and just like HashSet, they can be in whatever order Java decides to put them in. Generally speaking, Lists do maintain order a bit better than HashSets. The collections for both List and Set that maintain order is LinkedList and LinkedHashSet respectively. These will maintain their order of being added.

    • @CodingWithJohn
      @CodingWithJohn  Рік тому

      Hello, thanks for watching! I have to disagree though, ArrayList does maintain its insertion order. Feel free to Google around and look though. I'd be curious to see where you saw that it doesn't.

  • @jagan107
    @jagan107 2 роки тому

    Thank you John for make me understanding difference in using Set() and HashSet() i had this doubt for longer time. Time in the video: 3:12 to 4:21

  • @shafaatalizee8182
    @shafaatalizee8182 9 місяців тому

    Hi Dear Sir ! I'm associat java developer, and I love the way you delivered the topics, especially Hashset and HashMap because I was so confused on these before I watched your tutorials
    Thanks ❤

  • @jordanparsa7713
    @jordanparsa7713 2 роки тому +6

    Hey John! Your videos are helping me get through the most important internship of my life. THANK YOU. Humble Request: can you make a video covering serialization/deserialization?

  • @trustytrojan
    @trustytrojan Рік тому +1

    even though i knew all about java sets, i still watched this video to appreciate how well you teach these concepts.
    keep it up youre doing good work for the java community 🙏

  • @ayushmaansural4896
    @ayushmaansural4896 Рік тому +2

    Man respect ++ , The clarity you gave was commendable !

  • @evilman667
    @evilman667 Рік тому

    As a senior dev, i must say, watching your videos is very relaxing. Thank you.

  • @guzinreidelas
    @guzinreidelas Рік тому

    John, thank you so much for the Java lessons. As someone who is not fluent in English, having to read the error-filled UA-cam captions and follow the lesson at the same time, I actually understand your explanation better than my own professor's. Sending a warm embrace from Brazil!

    • @Robin-hi4vj
      @Robin-hi4vj Рік тому

      Que legal, Você siga em frente

  • @gerdsfargen6687
    @gerdsfargen6687 2 роки тому +4

    Da man is back! This dude has saved my Java bacon many times! These videos are the best.

  • @mastershonobi110
    @mastershonobi110 2 роки тому +1

    Very good vid. It covers all the good stuff in plain English. Thanks John.

  • @royalmech14
    @royalmech14 Рік тому

    John. Keep them coming. I’m from india. Haven’t seen anyone who speaks organised. Precised as you do. Love your work. Bless you ❤

  • @nabeelrehman5451
    @nabeelrehman5451 2 роки тому +8

    Great content as always, Please make a tutorial about java futures.

  • @federico42o
    @federico42o Рік тому

    Thanks John, with you I improve my code and my English. Greetings from Argentina

  • @zfazzershroudvietcynide64e58
    @zfazzershroudvietcynide64e58 5 місяців тому

    new subscriber here, your explanation is 80% more easier to understand than our teacher

  • @integralcialbay4633
    @integralcialbay4633 Рік тому +1

    Thanks for the great video! I really enjoyed and learned a lot from it. Just wanted to add one little thing about the difference between HashSet and TreeSet: Elements of a TreeSet need to implement either the Comparable interface or they need to come with a Comparator, since the TreeSet sorts them out whereas HashSet just places them based on HashCode. This is a very small difference, but it can be important sometimes.

  • @antonmariadas7747
    @antonmariadas7747 Рік тому +1

    Love your courses. Needed a reminder about sets and you made it crystal clear 😊

  • @ah_dev
    @ah_dev Рік тому +1

    your videos are helping me understand my Java coursework at Uni! Thanks for all you do John!

  • @mislam2565
    @mislam2565 11 місяців тому

    Simply Perfect and Perfectly Simple to Understand! Thanks a Ton!

  • @anpadjahil9711
    @anpadjahil9711 2 роки тому +2

    Thanks a lot for the simplicity!
    One question: while using hashset which way should we prefer and why:
    1 - Set s = new HashSet
    2 - HashSet hs = new HashSet

    • @drcl7429
      @drcl7429 2 роки тому

      it doesn't really matter. The advantage of creating a set variable is that it could potentially reference any of the types that implement the set interface. A hashset variable can only reference hashsets.

  • @sachinsonawane3767
    @sachinsonawane3767 Рік тому

    Found at right time. Just when I was feeling low and bored but wanted to explore set interface. Good explanation and examples thankyou

  • @abhijeetvdsh
    @abhijeetvdsh 10 місяців тому

    One of the best tutorial | Complete and Clear with examples

  • @kotyo82
    @kotyo82 2 роки тому

    beautiful explanation , i was worrying about this subject when i was listening my instructor several times ,; but after i found this video , Johns explanation ways very clear , understandable ,also polishing other knowledge of Java , if like button was real , i could destroy it , that much i like this .....thanks John

    • @drcl7429
      @drcl7429 2 роки тому +1

      Understanding interfaces is crucial to grasping this. So make sure you watch his video on it.

  • @letampatrickbienwi4610
    @letampatrickbienwi4610 7 місяців тому

    Don’t usually comment but great video , I learnt a lot and I can see the connection with data structures better. Thank you John!

  • @petergazer8321
    @petergazer8321 2 роки тому +3

    Thank you for all of your videos! You break it down in such an easy way to understand. Can you do a video sometime on serialization with examples and when to use it?

  • @aaron10k
    @aaron10k Рік тому

    my go to guy for java. I have an interview coming up at a hft firm if I get it I owe it all to u mr . John

  • @-karter-4556
    @-karter-4556 2 роки тому +1

    you dropped this king 👑

  • @gab1crazy
    @gab1crazy Рік тому

    maannn we just started studying hash and how it works and it's amazing. now I just found this video explaining it !!! THX SO MUCH (:

  • @michaelbistritzki7560
    @michaelbistritzki7560 Рік тому

    This is amazing! Now that I thought about it more deeply the idea is genius. I am studying the course on data structures and an introduction to algorithms and now I am thinking that it is possible, as you described at minute 13:15, to reduce the running time of searching for duplicates in a certain list from O(n^2) to O(n) just by using a HashSet. Thank you so much John for opening this thought to me, I will keep thinking about it in the future.Keep making more videos like this, it helps a lot!🤗

  • @SemiWagner
    @SemiWagner 2 роки тому +3

    I can't believe you just uploaded this video haha
    I am studying CS and this week's homework has to do with Collections and HashSet 😂

  • @NamNguyenHoang
    @NamNguyenHoang 5 місяців тому

    this is the best video about Set I have ever seen before, thank you so muchh

  • @olenashov5214
    @olenashov5214 2 роки тому

    Your explanation of Java makes it easier to understand. Thanks, John!

  • @m_i_g_u_e_l_
    @m_i_g_u_e_l_ 2 роки тому

    John you are the best java developer i know, thank you so much for share your knowledge.

  • @kcayushma
    @kcayushma 5 місяців тому +2

    Forward to 1:38

  • @MatthewWeiler1984
    @MatthewWeiler1984 2 роки тому +1

    Thanks for the video.
    I haven't really used Sets in the past.
    Looks like I have some refactoring to replace instances where I used a List just to keep track of unique entries.

  • @tabsc3489
    @tabsc3489 2 роки тому

    Ran into these at work today, so this is a nice coincidence! Thanks for the great tutorial

  • @martins2462
    @martins2462 Рік тому

    Good video.
    I would add, however, that instead of the natural ordering of type E, TreeSet can use a valid Comparator for type E, that is of type Comparator

  • @mannieg88
    @mannieg88 Рік тому

    Thank you, John, your explanations are very straightforward and easy to understand. I like the way you explain in the end how we can use data structures in real-world problems.

  • @MarianaRomeo-o1k
    @MarianaRomeo-o1k Рік тому

    Im a newbie and hash sets and sets always scared me! LOL now that you have taught me, I am seriously baffled.... Thank you so much

  • @semilife
    @semilife 11 місяців тому

    Thanks John, great clear concise videos. Perfect for a newbie and quick refresher.

  • @whiz-code
    @whiz-code 2 роки тому

    Am really really satisfied with the terms you use and the implementation of the concepts in a simple and easy to understand format. Thank you, Thank you, Thank you

  • @limiakejelu
    @limiakejelu Рік тому

    This guy is way too underrated! He’s the real G.O.A.T

  • @arthurmagamedov3179
    @arthurmagamedov3179 Рік тому

    Give a like before watching the video! And in respect to your work watching the mailgun presentation without skipping it!))

  • @khushboosoni4214
    @khushboosoni4214 5 місяців тому

    love the way u explain each and every details in your programs 😍

  • @ArturBerkut
    @ArturBerkut 2 роки тому

    100 times thank you!
    I learn English with and Java too
    So happy to find your channel here

  • @MahmudulIslam-l9x
    @MahmudulIslam-l9x Рік тому

    Your videos are really good and concise, gives me insight enough. Thanks.

  • @abhishekgowlikar
    @abhishekgowlikar Рік тому

    Love your videos, learned daily new topics, though the I am familiar with the topic, Presentation is crystal clear.

  • @motionattached
    @motionattached 5 місяців тому

    Your teaching style has performance edge, great job! 🕹

  • @ivaylokostadinov7543
    @ivaylokostadinov7543 2 роки тому +1

    Hi, John! Could you make a video explaining encapsulation? Your explanations make it so clear.

  • @ronneyismael5804
    @ronneyismael5804 2 роки тому

    John the way you explain is so good that I don't need to study Java Documentation. Keep it it up. Please also make a video on Marker interface and discuss about cloneable and serializable interface

  • @Timeless_Trader
    @Timeless_Trader 2 роки тому

    Thanks John, it was quite helpful to remember the working principle an difference between these.

  • @aidoka2000
    @aidoka2000 2 роки тому

    Awesome, concise and clear explanation. Thank you John. I even enjoy watching the topics I already know, because I just love your way of explaining them.

  • @ObieR
    @ObieR 2 роки тому +1

    This is awesome. Your videos have helped me so much. Thanks for all of your work.

  • @sachintiwari6065
    @sachintiwari6065 2 місяці тому +1

    ❤ very knowledgeable video ❤thanks

  • @girishanker3796
    @girishanker3796 2 роки тому +1

    Love your videos. So clear 🤌✨

  • @rashmiraj5269
    @rashmiraj5269 Рік тому

    It's called a wow video❤ thanks for making it easier

  • @kronosssssss
    @kronosssssss Рік тому

    Amazing pedagogical skills you have sir. Nice work and thank you

  • @karlcossaboon7072
    @karlcossaboon7072 8 місяців тому

    Absolute legend over here
    Thank you

  • @nathanherder1414
    @nathanherder1414 2 роки тому +2

    Love me some Breaking Bad mixed in with the examples. Thanks John!

  • @sadeepaalwis5938
    @sadeepaalwis5938 2 роки тому +1

    Thank you so much for the detailed explanation this is a gem 😍

  • @Devivl
    @Devivl 2 роки тому

    John, you're VERY cool at explaining complicated things in simple words. Thank you so much! Very cool!

  • @pranit_1643
    @pranit_1643 Рік тому

    Really loved the breaking bad context! kept me hooked up till the end.

  • @mikeyyy_xam
    @mikeyyy_xam 3 місяці тому

    i enjoy programming whenever i watch your videoss

  • @wikituby
    @wikituby Рік тому

    you are simply the best, can you please try to make videos more often, like twice a week or if possible three times a week

  • @chazzhorn7688
    @chazzhorn7688 Рік тому

    I love your way of explaining these concpts! Thanks John!

  • @davidwangonjo2041
    @davidwangonjo2041 Рік тому

    You made it look easy. Thank you John

  • @sumeetpachauri9577
    @sumeetpachauri9577 Рік тому +4

    bro binge watched Breaking bad right before shooting this

  • @FaridHasanaliyev
    @FaridHasanaliyev Рік тому +1

    Such a great videos!!! 🙂

  • @MzamoHerbza
    @MzamoHerbza Рік тому

    Absolutely clear and awesome quality, John. I love the content

  • @surajverma-ut4kj
    @surajverma-ut4kj Рік тому

    My favourite Java Guru❤

  • @igor9919
    @igor9919 8 місяців тому

    bros' videos are just gold

  • @KrzysztofChrzan
    @KrzysztofChrzan 8 місяців тому

    Very informative and usefull video. Cheers from Poland.

  • @yelizkosar3478
    @yelizkosar3478 2 роки тому

    I love your all videos. I improve myself with you Genius

  • @jermainscott6973
    @jermainscott6973 Рік тому

    I swear you are the best John 👊🏾

  • @laforever401
    @laforever401 Рік тому

    Wow! What an amazing video! Thank you so much for this!

  • @sanchalisharma9149
    @sanchalisharma9149 2 роки тому

    I loved it. I want more videos on collection frameworks. Also more on file handling and swing awt. Jdbc everything. I love your videos.

  • @deykumar5433
    @deykumar5433 Рік тому

    Hi John, I love the way you teach. I really appreciate your hard work and effort. It would be very helpful if you make a series on Dynamic Programming. You have that ability to make complex code easier. Thank you so much for your wonderful videos

  • @gowsikhaadevasenabathy
    @gowsikhaadevasenabathy Рік тому

    Hi John, your videos are extremely helpful for me as I have joined a software firm after a long career break with no prior experience in Java. Can you please do a video on Persistence since there are not many videos on this topic?

  • @travelwithannus
    @travelwithannus Рік тому +1

    Great Explanation. Plus You are a great fan of breaking bad :D

  • @lootster
    @lootster 6 місяців тому

    John is obviously a Breaking Bad fan. Thanks for this genius video explained so succinctly.

  • @bharatnaik5827
    @bharatnaik5827 2 місяці тому +1

    Very good explaination sir..🖖🖖

  • @adityapradhan8474
    @adityapradhan8474 Рік тому

    Very helpful video. You are a life saver man

  • @Namregnal
    @Namregnal Рік тому

    Hey John, great video as always.
    Any chance for a Comparator and Comparable video?
    Thank you!

  • @polimorphic13
    @polimorphic13 Рік тому

    Excellent video as always. Thank you John!

  • @summeray1
    @summeray1 Рік тому

    Great and simple explanation! Thanks!

  • @humzakhan766
    @humzakhan766 Рік тому

    Thank you john. Loved It. God bless you

  • @done_done_done_man
    @done_done_done_man 2 місяці тому

    Thanks this was super easy to understand

  • @tipeon
    @tipeon 2 роки тому

    I really like LinkedHashSet. I use it quite often. Sometimes for no other reason than to make debugging easier.

  • @humairahalimi3741
    @humairahalimi3741 Рік тому

    Thanks, this video was great, Very easy and clear explanation!

  • @marypaul9627
    @marypaul9627 4 місяці тому

    Thank you so much, I had to subscribe for this quality content.

  • @shadeismael7460
    @shadeismael7460 Рік тому

    thank you john , perfect explination . i can see that you are a big fan of breaking bad , that helped me to get more focused with you ;)