HashSet In Java Tutorial #52

  Рет қаралды 112,986

Alex Lee

Alex Lee

Күн бұрын

$1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 bit.ly/3HX970h
The HashSet in Java can be tricky at first. In this video I show you how you use the HashSet in Java! ✅Hopefully, what I've taught you will help you fix your HashSet Java code.
👑Start practicing now with 10 free java programs - alexlorenlee.com/
🐙 Source Code - github.com/ale...
Here are some useful HashSet Java methods:
hashset.add();
hashset.clear();
hashset.contains();
hashset.remove();
hashset.isEmpty();
hashset.iterator();
The HashSet in java code can be tricky at first... But SURELY you'll get it :) If you followed along, congrats! You learned-by-doing!
I hope you enjoyed this HashSet in Java tutorial! I like to have a nice mix of java tutorials and actual java programs for you all :)
Do you want to learn how to write java code from scratch, in Java? Check out my Java Tutorial For Beginners: • Coding For Beginners I...
Was this able to fix your Java Hashset code?
Full Java Tutorial For Beginners Playlist: • Full Java Course by Al...
Free Tips: bit.ly/3U6HXcb
Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.
~
Alex Lee

Пікірлер: 135
@alexlorenlee
@alexlorenlee 11 ай бұрын
If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h
@xxFivestarfreakxx
@xxFivestarfreakxx 3 жыл бұрын
dog.... i subscribed as soon as i seen the class name HashBrowns
@wewonbro1620
@wewonbro1620 3 жыл бұрын
Programming can be hard to learn by just reading. If only you knew how much and how fast I learn from your videos. I won't forget you when I make it to google.
@Sofien_Steve
@Sofien_Steve Жыл бұрын
The best java teacher on youtube
@mu-rad
@mu-rad 5 жыл бұрын
Your videos are great! Thanks!!
@rukna3775
@rukna3775 4 жыл бұрын
Then what's the difference between hashset and arraylist
@1komentator
@1komentator 4 жыл бұрын
Hashset doesn't accept duplicates, while arraylist do
@tomasjaron6869
@tomasjaron6869 4 жыл бұрын
Also you can't get let's say the 1. element from a hashset.
@rittenbrake1613
@rittenbrake1613 4 жыл бұрын
10:10 it is not a random number 42, is the sum of all the value ( 13 +24 +5 =42) , dunno what's mean by your "disperse" ,maybe we are talking about the same thing
@erlendor3332
@erlendor3332 3 жыл бұрын
That's true. But if you make a HashSet then the hashCode() will return a number once again. For example if the HashSet contains [a, b, c] then the hashCode(); returns 294
@jonathanjordan21
@jonathanjordan21 3 жыл бұрын
What is the difference between Hashset and ArrayList?
@jonathanjordan21
@jonathanjordan21 3 жыл бұрын
10:10 doesnt that the sum of the values?? 13 + 24 + 5 = 42
@LizyAd
@LizyAd 7 күн бұрын
Thanks so much!
@voidincognito4319
@voidincognito4319 4 жыл бұрын
Comment to show gratitude towards this whole channel... Hope you reach 1 mill subs soon!
@camm7766
@camm7766 4 жыл бұрын
This is an amazing channel
@WinterPhoenixForestKirin
@WinterPhoenixForestKirin 2 жыл бұрын
Great Harambe meme 👌 Rest in Power, Harambe ✊😤🤭
@johnfrog9210
@johnfrog9210 4 жыл бұрын
Thankyou for your videos, Why would you use a hashset and not an array to print out each value?
@deadpl55
@deadpl55 3 жыл бұрын
Plz tag me of someone answer
@AndrewSu180
@AndrewSu180 3 жыл бұрын
Hashsets do not allow duplicate data, that is probably the main reason to use a hashset over an array.
@arslanmehmood6371
@arslanmehmood6371 4 жыл бұрын
from now on i will call as alligators , diamonds are boring.
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
ducklips
@nanug6292
@nanug6292 4 жыл бұрын
Thanks it helped a lot
@jacke2678
@jacke2678 3 жыл бұрын
You could have explained the difference between a set and a list, they look very similar to me.
@Himanshu-xm8cw
@Himanshu-xm8cw 4 жыл бұрын
This was really helpful 🖖
@MJforall
@MJforall 2 жыл бұрын
Why are you not uploading video related Java
@arsenengenzi7852
@arsenengenzi7852 3 жыл бұрын
My man said "RIP Harambe" and I'm here for it 😂😂😂😂😂
@yeargun5582
@yeargun5582 4 жыл бұрын
HOOOOOOLY. That's strange 8:15 . Cause like, 24 is my favourite number aswell and i legit tell the same reason why i like that number ( Cause its divisible with a lot of numbers ). mhmh just wanted to share :)
@atakhanzhumadil8784
@atakhanzhumadil8784 4 жыл бұрын
and, Kobe Bryant's number
@floraposteschild4184
@floraposteschild4184 4 жыл бұрын
For Integers, anyway, the hashcode is the total of the numbers you put in.
@kajulooriraghu821
@kajulooriraghu821 2 ай бұрын
Awesome videos
@kakashi99908
@kakashi99908 2 жыл бұрын
What is the reason to use an iterator instead of a normal loop?
@heayyyyyyy11
@heayyyyyyy11 3 жыл бұрын
Thank you. Now i get it what my teacher can't tell me :D
@Ivan-ek6kg
@Ivan-ek6kg 4 жыл бұрын
what is the difference between Set set = new HashSet(); and HashSet set = new HashSet();
@anupriya1661
@anupriya1661 3 жыл бұрын
Hashset is a member of the collection set, so the object declared can be of both type, hashset or set, output will be same. Similar case with List list= new ArrayLIst() and List list= new LIst(), as arraylist is a member of collection List
@Ivan-ek6kg
@Ivan-ek6kg 3 жыл бұрын
@@anupriya1661 thx
@erikrl2
@erikrl2 2 жыл бұрын
@@anupriya1661 you cannot instantiate List as it's an interface.
@p2p2p2p2p2p
@p2p2p2p2p2p 4 жыл бұрын
Your videos are so useful! Can you make separate tutorial on Stringbuilder?
@BlazinPass
@BlazinPass 4 жыл бұрын
Congrats. You just fully replaced my professor. I should be paying you my tuition!
@aryankushwaha9306
@aryankushwaha9306 6 ай бұрын
can you plz tell us what are the difference btw the array list, HashSet, linked list, and array deque????
@huyn6977
@huyn6977 2 жыл бұрын
Hi Alex! first of all thank you very much! My question to you is what are the difrences between a Hashmap and a Hashset?
@anujkumarpatel2686
@anujkumarpatel2686 2 жыл бұрын
HashSet is a set, e.g. {1,2,3,4,5} HashMap is a key -> value (key to value) map, e.g. {a -> 1, b -> 2, c -> 2, d -> 1}
@huyn6977
@huyn6977 2 жыл бұрын
@@anujkumarpatel2686 thank you !
@nirmeenshamma1839
@nirmeenshamma1839 2 жыл бұрын
@@anujkumarpatel2686 Good explanation, Thank you!
@nawaraskc5610
@nawaraskc5610 4 жыл бұрын
Iterator is so confusing ....can someone help..??
@aye.myatmon4485
@aye.myatmon4485 Жыл бұрын
In HashSet , outputs are random why?
@daenzo3682
@daenzo3682 4 жыл бұрын
Good video, but flashing the patreon advertising with sound all 10 s is annoying. Doing this at the end of the video is better.
@iliasvenianakis4523
@iliasvenianakis4523 2 жыл бұрын
You show how to use but you didnt explained why we should prefer it or what exactly it does . God bless the deslike button that can not show anymore.
@iamarpit.
@iamarpit. 11 ай бұрын
it is showning red line under integer and saying that integer cannot resolved into a type pls suggest me what can i do......
@YokoYokoOneTwo
@YokoYokoOneTwo 3 жыл бұрын
useless video you should show the difference between arraylist and hashset instead of typing same code in each video
@Deepika-hm4br
@Deepika-hm4br 2 жыл бұрын
seems like a hashset is basically an appendable array that doesn’t allow for duplicates. are there any other benefits to using a hashset over an array
@tfh5575
@tfh5575 5 жыл бұрын
why am i so stupid ugh
@keenang09
@keenang09 3 жыл бұрын
If at all possible... a video on HashTables or maybe just a video illustrating the differences between types of Hashing
@aleksamarinkovic4363
@aleksamarinkovic4363 4 жыл бұрын
What is the difference between Hashset and Stringbuilder?
@aleksamarinkovic4363
@aleksamarinkovic4363 4 жыл бұрын
Stringbuilder is only for strings I guess but I think there is more to it
@navjotsingh2457
@navjotsingh2457 2 жыл бұрын
tysm
@AashrayNarangBCE
@AashrayNarangBCE 3 жыл бұрын
its really hard to see whats on the screen what you cant take your eyes off the bottom right corner.
@medoncho2397
@medoncho2397 2 жыл бұрын
Can somebody enlighten me, when are hash sets a good choice instead of other data structures?
@jaypatil9338
@jaypatil9338 3 жыл бұрын
Why 5 is printed..? Bt not 3 or 1
@rochdimaria
@rochdimaria 4 жыл бұрын
man you are the God of Java
@vishy
@vishy 4 жыл бұрын
Alex, please can you tell me the music you used at the end of the video?
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
darude sandstorm
@abdeselamselami4532
@abdeselamselami4532 4 жыл бұрын
Thanks a lot
@kwakukusi4094
@kwakukusi4094 3 жыл бұрын
does hashset allow duplicate values ?
@dr_ejahn
@dr_ejahn Жыл бұрын
bro realy said rip harambe hahhahahahhahaha
@guieltorres
@guieltorres 3 жыл бұрын
I have a hashset witch contains a Custom Object added. Example: private static Set people= new HashSet(); How can i create a function to retrieve a specific People to the hashset witch pass a People name? Ex: public People checkName(String name) { return // RETURN THE PEOPLE OF THE HASH CONTAINS name passed } please help me
@RobertGuilman
@RobertGuilman 3 жыл бұрын
Hmmm, what's the difference between HashSet and an ArrayList, apart from the name, it function almost the same with ArrayList... At least from the example you give
@shashikanth-v9k
@shashikanth-v9k 2 жыл бұрын
Iterator is it wrong?
@user-4538
@user-4538 2 жыл бұрын
Does anybody know how I can get that same list of options at 3:16 to appear in blueJ when I use classes from the java-library? That way I wouldn't have to go to their website everytime I want to explore the different methods of a java-library class? Is that possible to do in blueJ?
@reezyyy8800
@reezyyy8800 4 жыл бұрын
Can anybody tell me what's exactly the difference between a HashMap and a HashSet?
@venusisalwaysabove
@venusisalwaysabove 4 жыл бұрын
first of all, HashMap implements Map interface, but the HashSet implements Set interface.Beside that, the HashMap work with key and value; it cannot have duplicate keys (but it can have duplicate values). and it use Put() as the inserting method. HashSet, cannot have duplicate value . It use Add() as the inserting method . and its slower than HashMap.
@John-zs3jz
@John-zs3jz 3 жыл бұрын
@@venusisalwaysabove Also HashSet can only have 1 data type parameter, while HashMap can have 2.
@hafezpirzadeh2380
@hafezpirzadeh2380 4 жыл бұрын
Great video!
@chandureddy5208
@chandureddy5208 4 жыл бұрын
Good explanation, Thank you!
@anth7rax
@anth7rax 2 жыл бұрын
orangatang......................................
@caydaruuskayse4643
@caydaruuskayse4643 2 ай бұрын
Thanks sir
@ilyasilyas6252
@ilyasilyas6252 2 жыл бұрын
Broooooo I remember when you only had 100 views literally not to long ago lol!! You came a long way bro! Congrats
@maheshn6933
@maheshn6933 2 жыл бұрын
when you use hashcode, the result is sum of all number in the HashBrowns, is it something to be considered?
@ferfykins
@ferfykins 4 жыл бұрын
Excellent video, thanks!! I was wondering if you can have multiple types in parameter of hashset? for example: HashSet hashbrowns = new HashSet(); and if this is possible, how would the iterator handle multiple types? Thanks
@John-zs3jz
@John-zs3jz 3 жыл бұрын
I don't think you can have more than 1 data type parameter for HashSet, only for HashMap where there is a key and a value.
@kvelez
@kvelez Жыл бұрын
Very useful.
@Vithal_Nivargi
@Vithal_Nivargi 2 жыл бұрын
Nice explained sir thankyou
@rittenbrake1613
@rittenbrake1613 4 жыл бұрын
9:49 you are lovely for the your hand gesture
@anwarulbashirshuaib5673
@anwarulbashirshuaib5673 4 жыл бұрын
He could've admitted that he didn't know much about HashSets. The way he explained HashSets is not expected from a youtuber who uploads content to educate viewers
@maanialhdrami1187
@maanialhdrami1187 Жыл бұрын
Thank you so much, you really helped me
@anelemadonda6191
@anelemadonda6191 4 жыл бұрын
I liked the video as soon as he said RIP HArambe
@venusisalwaysabove
@venusisalwaysabove 4 жыл бұрын
write "sout" then CTRL+SPACE as a short cut for ''System.out.println()"
@rittenbrake1613
@rittenbrake1613 4 жыл бұрын
it's weird , some of his videos he did , some he didn't , maybe he is afraid of confusing people
@venusisalwaysabove
@venusisalwaysabove 4 жыл бұрын
@@rittenbrake1613 true, for me i was just trying to give it as a hint to others.
@rittenbrake1613
@rittenbrake1613 4 жыл бұрын
@@venusisalwaysabove yes sure ! It helps a lot , when I was a beginner , I dunno this shortcut too
@rittenbrake1613
@rittenbrake1613 4 жыл бұрын
@@venusisalwaysabove yes sure ! Thank you Ayoub ! It helps a lot , when I was a beginner , I dunno this shortcut too
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
sout tab
@EpicphoneGamer
@EpicphoneGamer 3 жыл бұрын
When do I use HashSets when programming in the field? What's the benefit?
@fridomaraya7438
@fridomaraya7438 3 жыл бұрын
so helpful but ,what is the difference with the Array List?
@keeprunning5457
@keeprunning5457 Жыл бұрын
gracias otra vez
@johnalsanamai-kurut338
@johnalsanamai-kurut338 3 жыл бұрын
what are the differences of hash-set and tree-set ?
@Rob-J-BJJ
@Rob-J-BJJ Жыл бұрын
the ordering is different tree-sets have natural ordering.
@En3rGyFaNforEv3r
@En3rGyFaNforEv3r 4 жыл бұрын
why dont you just use arrayList for everything?
@debasishsahu1556
@debasishsahu1556 2 жыл бұрын
Can we use (for each loop) in HasSet Just like You used While ?
@sofiasik8251
@sofiasik8251 2 жыл бұрын
"It's hashed all around so that's why it's called a hashSet" Gold. Good video! Thank you.
@deb5976
@deb5976 2 жыл бұрын
HashSet implements the set interface, that is one of the two main interfaces in the java collection.. There are a lot of things to learn about this hashSet object..
@joethompson8147
@joethompson8147 3 жыл бұрын
986 likes! Lets go people :) Great video Alex
@kevinfeng6700
@kevinfeng6700 3 жыл бұрын
"orangatang"
@friedchicken5227
@friedchicken5227 4 жыл бұрын
Thanks for flexing ur Mac :(
@kitty_kee
@kitty_kee 4 жыл бұрын
i like your IDE. Which is you using. Kindly tell me or paste link here so i can download
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
www.tomorrowtides.com/ictjournaldevfixed.html
@kitty_kee
@kitty_kee 4 жыл бұрын
@@sneakycheeky531 this link is dancing 💃
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
@@kitty_kee he's using eclipse. most software have there name at the top .
@kitty_kee
@kitty_kee 4 жыл бұрын
@@sneakycheeky531 exactly! 😎 now I have netBean IDE that is better than eclipse and parallel to Android Studio for making mobile apps. I recommend you to use netBeans.
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
@@kitty_kee im already using it. add me on discord disco#9740
@amitsarker9768
@amitsarker9768 4 жыл бұрын
Please consider describing the time complexity also.
@curesnow6493
@curesnow6493 3 жыл бұрын
Can you do hash table and priority queue?
@addayounes3950
@addayounes3950 3 жыл бұрын
what's the common uses of HashSet ? and why we need it when we have arrays and ArrayList ?
@Theuser2022
@Theuser2022 3 жыл бұрын
Hashsets are not index-based, they take the values inside the list randomly ~ I think they're used to generate random values (like unique keys). And are faster that Arraylist for searching the list.
@BIKE486
@BIKE486 4 жыл бұрын
What's the difference between hashSet and arrayList?
@sneakycheeky531
@sneakycheeky531 4 жыл бұрын
sets cant have duplicate values
@anwarulbashirshuaib5673
@anwarulbashirshuaib5673 4 жыл бұрын
9:48 If you are coming here to know why we call it HashSet then here's your answer 🤣😁
@GoodTimeDev
@GoodTimeDev 4 жыл бұрын
Quality stuff dude
@Hizbullla
@Hizbullla 5 жыл бұрын
Considering that this is a fairly new channel, I hope I can get this message across to you... What you are doing is great, your delivery is clear and concise, and in that regard, would it be possible to hold our hands through a relatively (to someone who had gone through the basic syntax) complex Java application, preferably a desktop with SQL queries and proper Swing usage? A lot of the code on KZbin is pretty much the onscreen creating of the source code with little to no explanation as to why we use what we just used, and it was be a massive help if you can make something similar giving us your logic and reasoning behind the work.
@michaelfortanely5715
@michaelfortanely5715 4 жыл бұрын
how do you know it was an inside job
@adireusch4522
@adireusch4522 4 жыл бұрын
Dude! You’re AMAZING!!!!!
@nikolaykolev89
@nikolaykolev89 3 жыл бұрын
Amazing!
@yicai7
@yicai7 4 жыл бұрын
Thanks dude!
@SatyamGupta-yq1pt
@SatyamGupta-yq1pt 2 жыл бұрын
op bro
@maazking9087
@maazking9087 5 жыл бұрын
hey thanks for explaining things so magically ..i have a question....its pretty much the same as a hashMap...then whats the difference.
@tarunmathur7797
@tarunmathur7797 4 жыл бұрын
HashMap also contains a key for its values
@mmahal
@mmahal 3 жыл бұрын
like for Harambe
@AliJardz
@AliJardz Жыл бұрын
Still giggling at harambe memes in 2023
@anwarulbashirshuaib5673
@anwarulbashirshuaib5673 4 жыл бұрын
Alex, please don't confuse your viewers with things that you don't know. The way you explained HashSets at 9:48 freaked me out. I hope you will upload content that you really know about and give the viewers a better understanding. Cheers 😁😁
@abhijitvetal576
@abhijitvetal576 4 жыл бұрын
learning with background music is fun pls do this for whole video
@Arrathix
@Arrathix 4 жыл бұрын
I get wanting to push your website and subscribe/like, etc, but those sound effects are so irritating and distracting that I'll probably never watch another one of your videos despite the good content. Seriously, don't ruin your product for the sake of advertising Alex; you already ask for support at the start of the video, don't go overboard.
@popflazh
@popflazh 3 жыл бұрын
10:11 I dont really understand what he meant by that. Can somebody explain?
@popflazh
@popflazh 3 жыл бұрын
Or wait.. is it the sum of all values?
@schajuli1991
@schajuli1991 3 жыл бұрын
Orangatang? Really that's the way how you spell it in english? :D
@sxmvp
@sxmvp 2 жыл бұрын
orangatang
Java Scope - Scope of Variables in Java Tutorial #53
9:57
Alex Lee
Рет қаралды 22 М.
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 220 М.
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
路飞与唐舞桐
Рет қаралды 10 МЛН
когда не обедаешь в школе // EVA mash
00:57
EVA mash
Рет қаралды 3,8 МЛН
Try Catch Java Tutorial #46
11:05
Alex Lee
Рет қаралды 218 М.
Access Modifiers Java Tutorial #82
11:27
Alex Lee
Рет қаралды 231 М.
Recursion Java Tutorial #69
9:07
Alex Lee
Рет қаралды 296 М.
Abstract Class In Java Tutorial #79
8:55
Alex Lee
Рет қаралды 542 М.
Inheritance in Java Tutorial #86
10:34
Alex Lee
Рет қаралды 385 М.
Queue In Java Tutorial #66
7:46
Alex Lee
Рет қаралды 137 М.
This Keyword in Java Tutorial #80
10:39
Alex Lee
Рет қаралды 182 М.
Static in Java Tutorial #75
6:16
Alex Lee
Рет қаралды 258 М.
Java Classes - How To Use Classes in Java #72
7:20
Alex Lee
Рет қаралды 318 М.