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

  Рет қаралды 183,353

Coding with John

Coding with John

3 жыл бұрын

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

Пікірлер: 249
@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!
@phillipmiller4642
@phillipmiller4642 Ай бұрын
Agreed
@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!
@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.❤
@iruga7379
@iruga7379 2 жыл бұрын
OMFG please keep your content comming...im having a blast learning from you man. Im deeply grateful for all your lessons.
@terrypark3690
@terrypark3690 8 ай бұрын
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.
@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.
@Visionist
@Visionist 3 жыл бұрын
Simple and easy to understand. Thank you!
@streamity24
@streamity24 2 жыл бұрын
Really fascinated at how good you are able to explain. Thanks for the great video!
@olivierbegassat851
@olivierbegassat851 11 ай бұрын
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 🙂
@manojpal4415
@manojpal4415 Жыл бұрын
Had been scratching my head on a case similar to the example at last, luckily this video explained it. Huge thanks :)
@ovey2214
@ovey2214 2 жыл бұрын
That was incredibly well explained! Thanks a lot!
@theFUNkaarasChannel
@theFUNkaarasChannel 2 жыл бұрын
I just found your channel and the world just makes so much more sense now.
@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!!!!
@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.
@alexanderpanday
@alexanderpanday 3 ай бұрын
go away bootcamp people
@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!
@jesusromero71
@jesusromero71 2 жыл бұрын
tus videos tienen un gran valor, muchas gracias por compartir tu conocimiento
@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.
@shubhamkatwale6716
@shubhamkatwale6716 2 жыл бұрын
Very well explained Jonh, Thanks again ♥
@wayneinteressierts9973
@wayneinteressierts9973 Жыл бұрын
Great video as always. Thank you for your dedication!
@elijahasefa389
@elijahasefa389 2 жыл бұрын
this channel always dropping gems. Respect.
@rahul64410
@rahul64410 2 жыл бұрын
Thanks for the video john seems like refreshing my basics
@shama-_-
@shama-_- Жыл бұрын
thanks a lot you help me to understand the concepts
@tonnytrumpet734
@tonnytrumpet734 Ай бұрын
Sir I have been watching your videos for around 30 hours last 3 days, thank you so much this is great content I am starting to actually understand Java and see how things from different videos relate to each other, sometimes I can guess what you are going into with your train of thoughts, very well put together videos.
@DatCrossGuy
@DatCrossGuy Жыл бұрын
Thanks so much for the video. Genuinely looking forward to the "how to write a good equals method" vid!
@harlockgaming1476
@harlockgaming1476 7 ай бұрын
Love the Kramer picture in the back, my grandpa has one just like it! Thanks for the amazing videos!
@eshwarnag
@eshwarnag 8 ай бұрын
the last part was really good!
@cananozdemir8913
@cananozdemir8913 6 ай бұрын
I just bought his full Java course. Amazing explanation .
@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?
@InfiniteWisdom1.0
@InfiniteWisdom1.0 7 ай бұрын
Thank you so much, your videos are pretty helpful 😊
@ruzi173
@ruzi173 10 ай бұрын
This is just the best explanation..wow👏Thank you for all your videos🙏
@amaralensheriff
@amaralensheriff Жыл бұрын
Thanks John, your tutorials are awesome.
@Eduardado
@Eduardado 2 жыл бұрын
Very clear. Awesome examples and also my eyes love the dark theme ^^
@LTZMSYAL
@LTZMSYAL Жыл бұрын
Thansk's John. Please don't stop your videos they are awesome
@strigidae8939
@strigidae8939 2 жыл бұрын
Love your videos bro. Very helpful. Thanks a lot
@ujjwals.dadwal8911
@ujjwals.dadwal8911 2 жыл бұрын
Thanks John, Mucha Gracias from Canada!
@thalathotitharunprabhakar3390
@thalathotitharunprabhakar3390 2 жыл бұрын
Easy to understand. Thank you.
@adamlasry5225
@adamlasry5225 2 жыл бұрын
Great lessons as usual. Thanks.
@user-dm8tm2pm9o
@user-dm8tm2pm9o 10 ай бұрын
Thx for your clear presentation Sir
@anjelomanoranjan
@anjelomanoranjan 10 ай бұрын
Thanks! Your videos are great!
@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!
@danieldanian8070
@danieldanian8070 Жыл бұрын
This guy is the best as a learner and teacher guide
@bhagyakavijan9014
@bhagyakavijan9014 Жыл бұрын
Thank you so much.. Your explanation is very clear...!!!
@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
@technicalboy1816
@technicalboy1816 2 жыл бұрын
I wish you were my lecturer at Uni. You have talent man!
@9891254408
@9891254408 Жыл бұрын
This is the best i have understoon so far...
@Coccoutube
@Coccoutube Жыл бұрын
Thanks John!
@robertod893
@robertod893 11 ай бұрын
Excellent video as always!
@cestmoi5248
@cestmoi5248 2 жыл бұрын
wow, very well explained. Thank you
@konstantinzakharov5643
@konstantinzakharov5643 Жыл бұрын
I love this guy! I am hitting the Like button!
@ayanokoji8456
@ayanokoji8456 Жыл бұрын
Wow thanks man it is so well explain !
@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
@mdemranalamin166
@mdemranalamin166 2 жыл бұрын
thank you, sir. !! great explanation.
@aymengouja3895
@aymengouja3895 Жыл бұрын
thanks a lot !!! awesome explanation
@lamaspacos
@lamaspacos 4 ай бұрын
This channel is very very good.
@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
@laurentlefevre9233
@laurentlefevre9233 2 жыл бұрын
Nice job John !
@potatofypotatofy7772
@potatofypotatofy7772 Жыл бұрын
Thank you John
@stacywen7908
@stacywen7908 Жыл бұрын
thank you so much! very helpful!
@altamashsabri8142
@altamashsabri8142 Жыл бұрын
Amazing explanation, thanks alot
@enfieldli9296
@enfieldli9296 2 жыл бұрын
Wow, noob here, didnt know those details till you explain it, massive thanks John!
@akna1987
@akna1987 5 ай бұрын
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
@lararifai7074
@lararifai7074 2 жыл бұрын
Very interesting ,thank you .
@surkesden
@surkesden 2 жыл бұрын
Good explanation! What about enum comparation? What should I use?
@YusufDemir-gx7he
@YusufDemir-gx7he 2 жыл бұрын
It seems I've found my coding channel. Thanks for the video :)
@scottcarter4526
@scottcarter4526 Жыл бұрын
Might also be worth mentioning that you can use == with enum's as well.
@saranr4878
@saranr4878 Жыл бұрын
Just the greatest explanation !
@bhukyasharath2015
@bhukyasharath2015 Жыл бұрын
Superb sir❤
@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 жыл бұрын
😂😂
@dylangovender
@dylangovender 2 жыл бұрын
Amazing tutorial!
@dolevlevi7826
@dolevlevi7826 3 жыл бұрын
love your videos man !
@pedroaboffa
@pedroaboffa 2 жыл бұрын
Thank you john!!
@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!
@adeebalaifan8684
@adeebalaifan8684 Жыл бұрын
Perfect concept
@NikolayTach
@NikolayTach 2 жыл бұрын
Good stuff brotherly.
@TeluguAbbai802
@TeluguAbbai802 2 жыл бұрын
Excellent teacher
@ThePiko69
@ThePiko69 2 жыл бұрын
Great lesson :)
@harshabhrito
@harshabhrito Ай бұрын
Thank you sir.
@anubhavsingh2916
@anubhavsingh2916 Жыл бұрын
To the point explanation
@thegloriousgoldeneagle
@thegloriousgoldeneagle 6 ай бұрын
I love your videos, thank you
@kilian9758
@kilian9758 8 ай бұрын
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?
@MarioVillamizar
@MarioVillamizar Жыл бұрын
Cristal clear!
@bextrekks8354
@bextrekks8354 2 жыл бұрын
lmao, that head pop up at the beginning cracks me up!
@medkamy2393
@medkamy2393 Жыл бұрын
Best tuto ever
@HR-pz7ts
@HR-pz7ts 11 ай бұрын
Once you learn a thing or two about oops you know exactly what's going on. Thank you for the video
@SecretFols
@SecretFols Жыл бұрын
The underline is even if the primitive or non primitive or user defined type java will check for the memory location and not the values.. (if the values are same then uses same memory location).
@borisvasilev4893
@borisvasilev4893 Жыл бұрын
Really Really cool!
@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!
@rafaybbx
@rafaybbx Жыл бұрын
ThankYou!!!
@findlestick
@findlestick 2 жыл бұрын
This is a very useful video.
@barathv9910
@barathv9910 2 жыл бұрын
Thank you
@marioathan99
@marioathan99 2 жыл бұрын
Thank you so much
@DanielOliveira-ru7mt
@DanielOliveira-ru7mt Жыл бұрын
Thanks Johnny Sins
@lyrixvibz
@lyrixvibz Ай бұрын
Please be polite with your words👍
@AdemHoskin
@AdemHoskin 13 күн бұрын
@@lyrixvibzhe said thank you
@lyrixvibz
@lyrixvibz 13 күн бұрын
@@AdemHoskindo you know Johnny sins?💀
@limonade-ru4vy
@limonade-ru4vy 2 ай бұрын
You are a genius!!
@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.
@streamcatcher2853
@streamcatcher2853 2 жыл бұрын
You are the best !
@bellum_7997
@bellum_7997 2 жыл бұрын
nice one John :)
@InfoBuzz1130
@InfoBuzz1130 Жыл бұрын
Hey pls make video on comparable comparator interface in java
@HackInTheBoxx
@HackInTheBoxx 2 жыл бұрын
Can you do a video sometime on instanceof, thank you.
@bardia6284
@bardia6284 Жыл бұрын
Thanks
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 509 М.
Exception Handling in Java Tutorial
13:20
Coding with John
Рет қаралды 374 М.
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 25 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 9 МЛН
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 35 МЛН
The purest coding style, where bugs are near impossible
10:25
Coderized
Рет қаралды 930 М.
Difference Between "== Operator" And "equals() Method" In Java (Hindi)
15:02
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 723 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 265 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2 МЛН
Primitives Data Types In Java - All the Primitives And What They Do
10:24
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,2 МЛН
Interview Question | Comparable vs Comparator in Java
12:58
Telusko
Рет қаралды 641 М.
Checked vs. Unchecked Exceptions in Java Tutorial - What's The Difference?
10:14
Новые iPhone 16 и 16 Pro Max
0:42
Romancev768
Рет қаралды 2,3 МЛН
Rate This Smartphone Cooler Set-up ⭐
0:10
Shakeuptech
Рет қаралды 6 МЛН