Тёмный

.equals() vs. == in Java - The Real Difference 

Coding with John
Подписаться 334 тыс.
Просмотров 177 тыс.
50% 1

Complete Java course: codingwithjohn.thinkific.com/...
Watch now to learn the difference between ".equals()" vs. "==" in Java. Full tutorial on the difference between "==" (double equals) and the ".equals()" method in Java. Especially for Strings, when do you use ==, and when do you use .equals?
Simple equality checks in Java can be tricky, but the facts are simpler than you may think.
This is a very beginner friendly beginner's Java coding lesson tutorial, where we'll discuss the difference between == and .equals() when doing equals checks in Java.
Learn or improve your Java by watching it being coded live!
Hey, I'm John! I'm a Lead Java Software Engineer who has been in the industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java developers.
Let me know what else you'd like to see!
Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.
📕 THE best book to learn Java, Effective Java by Joshua Bloch
amzn.to/36AfdUu
📕 One of my favorite programming books, Clean Code by Robert Martin
amzn.to/3GTPVhf
🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial
www.audibletrial.com/johnclean...
🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)
bit.ly/3QPNGko
📹Phone I use for recording:
amzn.to/3HepYJu
🎙️Microphone I use (classy, I know):
amzn.to/3AYGdbz
Donate with PayPal (Thank you so much!)
www.paypal.com/donate/?hosted...
☕Complete Java course:
codingwithjohn.thinkific.com/...
codingwithjohn.com

Наука

Опубликовано:

 

29 янв 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 239   
@rykageee
@rykageee 3 года назад
so far I've watched several videos with the same topic but this video only explained well. Thanks man!
@CodingWithJohn
@CodingWithJohn 3 года назад
Awesome! Very glad I was able to help!
@DanielOliveira-ru7mt
@DanielOliveira-ru7mt Год назад
Thanks Johnny Sins
@Daresigmally
@Daresigmally Год назад
Oh my god I'm genuinely so thankful I discovered this Channel, John explains stuff like no one else does, you just earned yourself a subscriber mate, thank you for all the efforts.❤
@cjm101
@cjm101 Год назад
Feeling lucky to have found this channel, I've been self studying on and off for a couple years and I'm pretty sure I should have known these key concepts by now, sincere thanks for these clear and understandable teachings!
@praveens9233
@praveens9233 Год назад
Warning ⚠️ : If you are going to override .equals method,you have to override your hascode method. Otherwise there will be a mess with those objects whenever you hashing
@Visionist
@Visionist 3 года назад
Simple and easy to understand. Thank you!
@aureliasam2092
@aureliasam2092 2 года назад
Hi John you did very well in this lesson. I tried to learn .equals and == from a professor but I couldn't understand it and now I got the point from you in 5 minutes.
@terrypark3690
@terrypark3690 6 месяцев назад
wow this goes well with your string pool video. Thanks for making these really comprehensive videos on how java works for the basic things we just usually use without thinking about.
@olivierbegassat851
@olivierbegassat851 9 месяцев назад
These are beautiful videos man 😁 Every sentence of yours resolves an issue I had and leads to the next question I had. So helpful ! Thanks 🙂
@iruga7379
@iruga7379 Год назад
OMFG please keep your content comming...im having a blast learning from you man. Im deeply grateful for all your lessons.
@streamity24
@streamity24 Год назад
Really fascinated at how good you are able to explain. Thanks for the great video!
@ovey2214
@ovey2214 2 года назад
That was incredibly well explained! Thanks a lot!
@manojpal4415
@manojpal4415 Год назад
Had been scratching my head on a case similar to the example at last, luckily this video explained it. Huge thanks :)
@WildNature170
@WildNature170 Год назад
Ah Lord! can't just say how easy you explained it. I have been really confused for several days about this simple .equals in object class and now I know how java processes it. Thank you so much for this video. Subscribed liked and commented. Keep up with your good work!!!!
@theFUNkaarasChannel
@theFUNkaarasChannel 2 года назад
I just found your channel and the world just makes so much more sense now.
@magicalhats
@magicalhats 2 года назад
I'm a newbie dev and I finished a bootcamp but your videos topics are all the topics I found confusing during class and always wondered about. TY so much.
@techexpert5600
@techexpert5600 28 дней назад
go away bootcamp people
@dotanon
@dotanon Год назад
I got back into Java recently after not using it for like 8 years and have been haphazardly using == for strings and it has been working, presumably because I have been always using strings as state variables in games, and so have been manually typing the strings in my conditions as literals (if (facing == "up")) etc. I saw a comment on another video and I'm glad I found this early enough to refactor everything. haha.
@Fawstah
@Fawstah Год назад
This actually helped me understand why some of the code I was writing was initially breaking. Ty!
@michael_scarn_
@michael_scarn_ Год назад
Thanks John, your tutorials are very helpful. You are a great teacher, hats off!
@shubhamkatwale6716
@shubhamkatwale6716 2 года назад
Very well explained Jonh, Thanks again ♥
@elijahasefa389
@elijahasefa389 2 года назад
this channel always dropping gems. Respect.
@jesusromero71
@jesusromero71 2 года назад
tus videos tienen un gran valor, muchas gracias por compartir tu conocimiento
@cananozdemir8913
@cananozdemir8913 4 месяца назад
I just bought his full Java course. Amazing explanation .
@ruzi173
@ruzi173 8 месяцев назад
This is just the best explanation..wow👏Thank you for all your videos🙏
@rahul64410
@rahul64410 2 года назад
Thanks for the video john seems like refreshing my basics
@wayneinteressierts9973
@wayneinteressierts9973 Год назад
Great video as always. Thank you for your dedication!
@harlockgaming1476
@harlockgaming1476 5 месяцев назад
Love the Kramer picture in the back, my grandpa has one just like it! Thanks for the amazing videos!
@DatCrossGuy
@DatCrossGuy Год назад
Thanks so much for the video. Genuinely looking forward to the "how to write a good equals method" vid!
@ujjwals.dadwal8911
@ujjwals.dadwal8911 2 года назад
Thanks John, Mucha Gracias from Canada!
@eshwarnag
@eshwarnag 6 месяцев назад
the last part was really good!
@amaralensheriff
@amaralensheriff Год назад
Thanks John, your tutorials are awesome.
@LTZMSYAL
@LTZMSYAL Год назад
Thansk's John. Please don't stop your videos they are awesome
@shama-_-
@shama-_- Год назад
thanks a lot you help me to understand the concepts
@colonelh.s.l.3834
@colonelh.s.l.3834 Год назад
This is awesome! Can you do a video on priority queues and comparators, and how they come together?
@Eduardado
@Eduardado 2 года назад
Very clear. Awesome examples and also my eyes love the dark theme ^^
@user-dm8tm2pm9o
@user-dm8tm2pm9o 8 месяцев назад
Thx for your clear presentation Sir
@InfiniteWisdom1.0
@InfiniteWisdom1.0 5 месяцев назад
Thank you so much, your videos are pretty helpful 😊
@strigidae8939
@strigidae8939 2 года назад
Love your videos bro. Very helpful. Thanks a lot
@thalathotitharunprabhakar3390
@thalathotitharunprabhakar3390 2 года назад
Easy to understand. Thank you.
@bhagyakavijan9014
@bhagyakavijan9014 Год назад
Thank you so much.. Your explanation is very clear...!!!
@adamlasry5225
@adamlasry5225 2 года назад
Great lessons as usual. Thanks.
@anjelomanoranjan3908
@anjelomanoranjan3908 8 месяцев назад
Thanks! Your videos are great!
@robertod893
@robertod893 9 месяцев назад
Excellent video as always!
@danieldanian8070
@danieldanian8070 Год назад
This guy is the best as a learner and teacher guide
@the_Spartan_117
@the_Spartan_117 Год назад
By the beard of Zeus! Your contributions to the world of programming are nothing short of epic. Your Java beginner's playlist is truly a stroke of genius, and I speak for many when I say, you are the real MVP!
@dhavewala
@dhavewala 2 года назад
John, this was an amazing tutorial! I had a query though; on the objects, do we override the equals() or is it inferred?
@wiktorstankiewicz3568
@wiktorstankiewicz3568 2 года назад
we override it
@fullfungo
@fullfungo 2 года назад
6:15
@surkesden
@surkesden 2 года назад
Good explanation! What about enum comparation? What should I use?
@cestmoi5248
@cestmoi5248 2 года назад
wow, very well explained. Thank you
@technicalboy1816
@technicalboy1816 2 года назад
I wish you were my lecturer at Uni. You have talent man!
@lamaspacos
@lamaspacos 2 месяца назад
This channel is very very good.
@altamashsabri8142
@altamashsabri8142 Год назад
Amazing explanation, thanks alot
@brtkgromek
@brtkgromek 2 года назад
I'm glad I've found this chanel. I've never been more educated by any other escaped convict in my entire life! Keep it up! :)
@enigma6463
@enigma6463 2 года назад
😂😂
@mdemranalamin166
@mdemranalamin166 2 года назад
thank you, sir. !! great explanation.
@GenjaOrigins
@GenjaOrigins 2 года назад
You are great. Congrats for channel and being Team Leader. Maybe you could/should make a video talking about what should a junior know. I think i know equals now, exceptions/throw/finally/catch etc, im learning generics and i undertand but i saw a generic method in an interview(company was about HR, and i was asked 4 Design Patterns which i knew but wasnt good enough for company anyway) i had no idea what it was even if i knew generics it was kind of pro code/ultra weird and hard i think it was with lists btw..i also hate leetcode i prefer videos like yours to actually learn java. I would also learn more from you cause you good and you enjoyable i hope you do the same in your job irl. i think i also know most of collections hashmap/set etc
@ayanokoji8456
@ayanokoji8456 Год назад
Wow thanks man it is so well explain !
@9891254408
@9891254408 Год назад
This is the best i have understoon so far...
@enfieldli9296
@enfieldli9296 Год назад
Wow, noob here, didnt know those details till you explain it, massive thanks John!
@akna1987
@akna1987 3 месяца назад
These videos are great! But you should have included a video on how to implement the .equals-method and compare-to method to your own class
@aymengouja3895
@aymengouja3895 Год назад
thanks a lot !!! awesome explanation
@laurentlefevre9233
@laurentlefevre9233 2 года назад
Nice job John !
@stacywen7908
@stacywen7908 Год назад
thank you so much! very helpful!
@kilian9758
@kilian9758 5 месяцев назад
Your tutorials are awesome! Though I wonder if this affects switch cases too. Can I always use switch cases or do I need to be cautious just like with the == operator?
@YusufDemir-gx7he
@YusufDemir-gx7he 2 года назад
It seems I've found my coding channel. Thanks for the video :)
@micahrufsvold
@micahrufsvold 2 года назад
Small piece of feedback: title shoulda been ".equals() and == are not equal" Thanks for the great video!
@CodingWithJohn
@CodingWithJohn 2 года назад
.equals() != ==
@micahrufsvold
@micahrufsvold 2 года назад
@@CodingWithJohn even better!
@konstantinzakharov5643
@konstantinzakharov5643 10 месяцев назад
I love this guy! I am hitting the Like button!
@lararifai7074
@lararifai7074 2 года назад
Very interesting ,thank you .
@dylangovender
@dylangovender Год назад
Amazing tutorial!
@saranr4878
@saranr4878 Год назад
Just the greatest explanation !
@Coccoutube
@Coccoutube Год назад
Thanks John!
@potatofypotatofy7772
@potatofypotatofy7772 Год назад
Thank you John
@bhukyasharath2015
@bhukyasharath2015 Год назад
Superb sir❤
@dolevlevi7826
@dolevlevi7826 2 года назад
love your videos man !
@simonjunior184
@simonjunior184 2 года назад
Amazing explanation. My Uni java lecturer even didn't taught us this important concept. Keep up the great job!
@ThePiko69
@ThePiko69 2 года назад
Great lesson :)
@NikolayTach
@NikolayTach 2 года назад
Good stuff brotherly.
@findlestick
@findlestick 2 года назад
This is a very useful video.
@thegloriousgoldeneagle
@thegloriousgoldeneagle 4 месяца назад
I love your videos, thank you
@pedroaboffa
@pedroaboffa 2 года назад
Thank you john!!
@TeluguAbbai802
@TeluguAbbai802 2 года назад
Excellent teacher
@adeebalaifan8684
@adeebalaifan8684 Год назад
Perfect concept
@galirams9653
@galirams9653 10 дней назад
John, please clarify this for me, in text, how would you declare and compare 2 string objects for equality?
@anubhavsingh2916
@anubhavsingh2916 Год назад
To the point explanation
@scottcarter4526
@scottcarter4526 Год назад
Might also be worth mentioning that you can use == with enum's as well.
@MarioVillamizar
@MarioVillamizar Год назад
Cristal clear!
@bextrekks8354
@bextrekks8354 2 года назад
lmao, that head pop up at the beginning cracks me up!
@AHMED-ry2gy
@AHMED-ry2gy 2 года назад
dude, your videos are amazing
@pankajthorat4606
@pankajthorat4606 2 года назад
I am going through you video and its very easy to understand . One more request can you please provide session for Stack vs heap memory.
@HR-pz7ts
@HR-pz7ts 9 месяцев назад
Once you learn a thing or two about oops you know exactly what's going on. Thank you for the video
@danielcommins1285
@danielcommins1285 2 года назад
John, where did you get the source and how did you attach the source to the binaries? UPDATE: solution is to point your JRE path to the path with the JDK instead!
@borisvasilev4893
@borisvasilev4893 Год назад
Really Really cool!
@rafaybbx
@rafaybbx Год назад
ThankYou!!!
@medkamy2393
@medkamy2393 Год назад
Best tuto ever
@Zuppermam1234
@Zuppermam1234 2 года назад
Thank you so much
@limonade-ru4vy
@limonade-ru4vy 6 дней назад
You are a genius!!
@glenn8781
@glenn8781 2 года назад
Can you please make that video you promised on writing a good equals method?
@bellum_7997
@bellum_7997 2 года назад
nice one John :)
@barathv9910
@barathv9910 2 года назад
Thank you
@user-qw9gr4cb8z
@user-qw9gr4cb8z Год назад
You explained sth in 8minutes that my French prof couldn’t explain in 2 hours and made me hate Java for no reason . Thank you ❤
@cryptoInNutshellR
@cryptoInNutshellR Год назад
Thanks. Useful, however you still did not cover how to compare 2 objects on the Dog example staring from 05:08
@streamcatcher2853
@streamcatcher2853 2 года назад
You are the best !
@pichou3614
@pichou3614 2 года назад
Amazing!
Далее
Lambda Expressions in Java - Full Simple Tutorial
13:05
Arigato !! 😂
00:11
Просмотров 2,1 млн
Sprinting with More and More Money
00:29
Просмотров 38 млн
but what is 'a lifetime?
12:20
Просмотров 57 тыс.
Exception Handling in Java Tutorial
13:20
Просмотров 354 тыс.
Interview Question | Comparable vs Comparator in Java
12:58
Java - Compare the Objects using equals() & hashCode()
16:16
Generics In Java - Full Simple Tutorial
17:34
Просмотров 1 млн
Redis Crash Course
27:31
Просмотров 592 тыс.
WHY IS THE STACK SO FAST?
13:46
Просмотров 131 тыс.
Индуктивность и дроссель.
1:00
Apple watch hidden camera
0:34
Просмотров 52 млн