so far I've watched several videos with the same topic but this video only explained well. Thanks man!
@CodingWithJohn3 жыл бұрын
Awesome! Very glad I was able to help!
@phillipmiller46425 ай бұрын
Agreed
@Dare242 жыл бұрын
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.❤
@magicalhats2 жыл бұрын
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.
@alexanderpanday6 ай бұрын
go away bootcamp people
@aureliasam20922 жыл бұрын
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.
@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!
@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.
@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
@Visionist3 жыл бұрын
Simple and easy to understand. Thank you!
@theFUNkaarasChannel2 жыл бұрын
I just found your channel and the world just makes so much more sense now.
@brtkgromek2 жыл бұрын
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! :)
@enigma64632 жыл бұрын
😂😂
@iruga73792 жыл бұрын
OMFG please keep your content comming...im having a blast learning from you man. Im deeply grateful for all your lessons.
@streamity242 жыл бұрын
Really fascinated at how good you are able to explain. Thanks for the great video!
@micahrufsvold2 жыл бұрын
Small piece of feedback: title shoulda been ".equals() and == are not equal" Thanks for the great video!
@CodingWithJohn2 жыл бұрын
.equals() != ==
@micahrufsvold2 жыл бұрын
@@CodingWithJohn even better!
@terrypark3690 Жыл бұрын
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.
@danieldanian80702 жыл бұрын
This guy is the best as a learner and teacher guide
@ovey22142 жыл бұрын
That was incredibly well explained! Thanks a lot!
@cananozdemir89139 ай бұрын
I just bought his full Java course. Amazing explanation .
@Fawstah Жыл бұрын
This actually helped me understand why some of the code I was writing was initially breaking. Ty!
@dhavewala2 жыл бұрын
John, this was an amazing tutorial! I had a query though; on the objects, do we override the equals() or is it inferred?
@wiktorstankiewicz35682 жыл бұрын
we override it
@fullfungo2 жыл бұрын
6:15
@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!
@manojpal44152 жыл бұрын
Had been scratching my head on a case similar to the example at last, luckily this video explained it. Huge thanks :)
@olivierbegassat851 Жыл бұрын
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 🙂
@tonnytrumpet7345 ай бұрын
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.
@enfieldli92962 жыл бұрын
Wow, noob here, didnt know those details till you explain it, massive thanks John!
@harlockgaming147611 ай бұрын
Love the Kramer picture in the back, my grandpa has one just like it! Thanks for the amazing videos!
@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!!!!
@BelayeAssefa13 жыл бұрын
this channel always dropping gems. Respect.
@HR-pz7ts Жыл бұрын
Once you learn a thing or two about oops you know exactly what's going on. Thank you for the video
@jesusromero712 жыл бұрын
tus videos tienen un gran valor, muchas gracias por compartir tu conocimiento
@nilou-s8l2 жыл бұрын
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 ❤
@scottcarter45262 жыл бұрын
Might also be worth mentioning that you can use == with enum's as well.
@DatCrossGuy2 жыл бұрын
Thanks so much for the video. Genuinely looking forward to the "how to write a good equals method" vid!
@technicalboy18162 жыл бұрын
I wish you were my lecturer at Uni. You have talent man!
@michael_scarn_ Жыл бұрын
Thanks John, your tutorials are very helpful. You are a great teacher, hats off!
@LTZMSYAL2 жыл бұрын
Thansk's John. Please don't stop your videos they are awesome
@ujjwals.dadwal89112 жыл бұрын
Thanks John, Mucha Gracias from Canada!
@pawehericht26735 ай бұрын
at 1:46 it is worth saying, that String one = "1"; String oneBis = "1"; when comparing one == oneBis will output true? what has changed and why String one = new String("1) gives us false when ==? The answer is: The String pool I believe
@akna19879 ай бұрын
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
@danielcommins12852 жыл бұрын
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!
@98912544082 жыл бұрын
This is the best i have understoon so far...
@YusufDemir-gx7he2 жыл бұрын
It seems I've found my coding channel. Thanks for the video :)
@MasonJF2 жыл бұрын
See this is interesting, because I thought with Javas memory management scheme that it uses and forces strings to be immutable would reference the same object in memory, even though the variables are two seperate ones. Eg. I was under the impression that String string1 = "James"; String string2 = "James"; these would both point to the same object in memory because these are the same value, which you would think would cause the == operator to go "Oh hey, this is true!".
@ruzi173 Жыл бұрын
This is just the best explanation..wow👏Thank you for all your videos🙏
@Eduardado2 жыл бұрын
Very clear. Awesome examples and also my eyes love the dark theme ^^
@brunomartel4639 Жыл бұрын
is it too bad if we declare Strings as literal all the time? like String string1= "hello" instead a declaring an object with it? I mean is there a reason to declare an object String?.
@alyankhan8062 жыл бұрын
The API contract also states that if you override equals() then you must override the hashcode(), it's an important detail!
@GenjaOrigins3 жыл бұрын
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
@rahul644102 жыл бұрын
Thanks for the video john seems like refreshing my basics
@shubhamkatwale67162 жыл бұрын
Very well explained Jonh, Thanks again ♥
@amaralensheriff Жыл бұрын
Thanks John, your tutorials are awesome.
@eshwarnag Жыл бұрын
the last part was really good!
@hba60182 жыл бұрын
String Pool, the place where are inline strings are saved, that's why you use new String("hello")
@علیحمیدی-س2ر Жыл бұрын
Thx for your clear presentation Sir
@lamaspacos8 ай бұрын
This channel is very very good.
@DanielOliveira-ru7mt Жыл бұрын
Thanks Johnny Sins
@lyrixvibz5 ай бұрын
Please be polite with your words👍
@1blkvinci4 ай бұрын
@@lyrixvibzhe said thank you
@lyrixvibz4 ай бұрын
@@1blkvincido you know Johnny sins?💀
@SifatUllah-123 ай бұрын
@@1blkvinciThat's not the right way to say thank you.
@JPS13Laptop2 жыл бұрын
As a python programmer, I definitely see myself getting confused if I were to ever get into Java. Thanks for the explanation :)
@tazogochitashvili65142 жыл бұрын
You shouldn't look too deep into the difference between "is" and "=" in python then lol
@JPS13Laptop2 жыл бұрын
@@tazogochitashvili6514 I actually do realise the difference between the two. But I don't use 'is' in my own code tbh. Also it annoys me that Java uses == for object comparison whereas Python uses it for value comparison.
@palmolive45412 жыл бұрын
@@JPS13Laptop Java doesn’t use == for object comparison, that was the whole point of this video
@JPS13Laptop2 жыл бұрын
@@palmolive4541 It appears that I still don't fully grasp what an object is. Also it seems that `is` in Python is what `==` does in Java, which is still annoying tbh.
@tazogochitashvili65142 жыл бұрын
@@JPS13Laptop that means that you don't understand either "is" in python or "==" in Java
@Loghinesko Жыл бұрын
The "new" keyword means that when we use it to create an instance of a class, we tell the computer that we want to allocate memory space to put the new object in.... After that, we want to create a new object again in the class, so we need to use the "new" keyword again which again tells the computer that we want to allocate memory for the new object, so it allocates a new memory address to the new object. Right now, we have the 2 objects, but they have different memory addresses because they were instantiated in different memory areas. When we compare objects, we are actually comparing the memory addresses of variables (objects). In fact, these variables are pointers to objects.
@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).
@colonelh.s.l.3834 Жыл бұрын
This is awesome! Can you do a video on priority queues and comparators, and how they come together?
@Zalaniar2 жыл бұрын
I was gonna say something about the weird use of a string constructor at the beginning, but it's a good thing I decided to wait, lol. IIRC, the javadoc even yells at people about wanting to use == for strings which I find hilarious.
@Zalaniar2 жыл бұрын
In case anyone is worried about java doubling up on references to strings like that causing weird bugs, don't worry... because strings are immutable, if you try to change one, java will just make a new String object and point the variable to that one instead, leaving the first untouched.
@wayneinteressierts9973 Жыл бұрын
Great video as always. Thank you for your dedication!
@Amy-zb4iq2 жыл бұрын
What’s the codes for .equals() in class Dog?
@surkesden2 жыл бұрын
Good explanation! What about enum comparation? What should I use?
@iyhan19872 жыл бұрын
7:03 I guess almost everyone(who studies Java seriously) knows about the pool of strings cause it is a pretty common topic. I bet if you want really “to impress some nerds” you should show them some “pool of Integer” style tricks :)
@ernestoc.d.18683 жыл бұрын
I would like to see the "How to implement a good .equals() method".
@inx18192 жыл бұрын
Step 1. Use Lombok
@wannabeserpento992 жыл бұрын
Eclipse can generate one for you and I don't know why he doesn't mention it
@Pacvalham2 жыл бұрын
1. check for identity (if(this == obj) return true;) 2. check for type (if(!(obj instanceof _ThisClass_ )) return false;) 3.a cast the object ( _ThisClass_ castObj = ( _ThisClass_ ) obj;) 3.b compare each field (return this.a == _[or .equals()]_ castObj.a && this.b == _[or .equals()]_ castObj.b && ...;)
@shama-_- Жыл бұрын
thanks a lot you help me to understand the concepts
@bhagyakavijan90142 жыл бұрын
Thank you so much.. Your explanation is very clear...!!!
@saranr48782 жыл бұрын
Just the greatest explanation !
@simonjunior1843 жыл бұрын
Amazing explanation. My Uni java lecturer even didn't taught us this important concept. Keep up the great job!
@thalathotitharunprabhakar33902 жыл бұрын
Easy to understand. Thank you.
@konstantinzakharov5643 Жыл бұрын
I love this guy! I am hitting the Like button!
@robertod893 Жыл бұрын
Excellent video as always!
@medkamy2393 Жыл бұрын
Best tuto ever
@provokator-provocateur76032 жыл бұрын
Best intro ever
@radhemohannaamhai2 жыл бұрын
Man they rejected me yesterday based on this question
@galirams96536 ай бұрын
John, please clarify this for me, in text, how would you declare and compare 2 string objects for equality?
@GaryChike2 жыл бұрын
This is a gotcha for those coming from C#. Great explanation John!
@potatofypotatofy7772 Жыл бұрын
Thank you John
@InfoBuzz1130 Жыл бұрын
Hey pls make video on comparable comparator interface in java
@Sui-Zan2 жыл бұрын
Orange is the new black, John. You look great! Thank you very much for the videos. You make java seem so simple to me.
@MarioVillamizar2 жыл бұрын
Cristal clear!
@InfiniteWisdom1.011 ай бұрын
Thank you so much, your videos are pretty helpful 😊
@anubhavsingh2916 Жыл бұрын
To the point explanation
@technoultimategaming29992 жыл бұрын
And it's very intuitive why == cannot always work. If you have a Room class and you ask java to check if a room is equals to another room... Well... It doesn't know what to check, should it check dimensions of the room, should it check furniture inside? While with numbers it's very obvious what people mean when one number equals another, but for objects like rooms it's really up to the programer to define what "equals" actually means
@Coccoutube2 жыл бұрын
Thanks John!
@laurentlefevre92332 жыл бұрын
Nice job John !
@HackInTheBoxx2 жыл бұрын
Can you do a video sometime on instanceof, thank you.
@kilian975811 ай бұрын
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?
@bhukyasharath2015 Жыл бұрын
Superb sir❤
@barneylaurance18652 жыл бұрын
I would call `==` the identity operator. It tells us if the two things are identical, not just if they are equal. In the real world two mass produced objects, like two coffee cups might be equal in every aspect you can measure, but they are not identical because they are two distinct objects.
@Programming-for-all-u2l2 жыл бұрын
Excellent teacher
@cestmoi52482 жыл бұрын
wow, very well explained. Thank you
@jeffreydwightryanriley83082 жыл бұрын
Is variable type even necessary? That’s why I like php. The types can be manipulated in the database and queries are objects. It allows synthetic interaction essentially in that the programmer ultimately codes states versus implicit phases of data. Such as arrays of arrays.
@bextrekks83542 жыл бұрын
lmao, that head pop up at the beginning cracks me up!
@altamashsabri81422 жыл бұрын
Amazing explanation, thanks alot
@findlestick3 жыл бұрын
This is a very useful video.
@cryptoInNutshellR Жыл бұрын
Thanks. Useful, however you still did not cover how to compare 2 objects on the Dog example staring from 05:08