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.❤
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.
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!
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.
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.
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.
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.
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
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!!!!
Thank you so much! You solved a bunch of hurdles I was facing while coding in Java. You earned a new Subscriber! By the way, what program are you using to code?
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?.
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!
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
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!
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).
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!".
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.
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 :)
But in your strings are immutable video, you said when initializing a string variable java points it to a pre existing string memory address. With that, here hello is already exist when you initialize the second string. Therefore both variable should point to same address, that is using == returns true. ? I am confused plz answer me.
the string itself is probably wrapped in a class and the class stores the reference to the string pool but the objects are initialized in different memory regions
I was thinking about the same, @john could you please clarify this question Here is the other video of your we were referring to 🙂 th-cam.com/video/Bj9Mx_Lx3q4/w-d-xo.html
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
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?
@@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.
@@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.
Hello John, please answer why i am getting false in first case? String str1 = new String("hello"); String str2 = new String("hello"); System.out.println(str1.equals(str2)); and String str = new String("java"); String rev = new String("avaj"); System.out.println(str.equals(rev)); how string comparision is done, is it character by character?
so far I've watched several videos with the same topic but this video only explained well. Thanks man!
Awesome! Very glad I was able to help!
Agreed
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.❤
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.
go away bootcamp people
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!
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.
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.
Simple and easy to understand. Thank you!
OMFG please keep your content comming...im having a blast learning from you man. Im deeply grateful for all your lessons.
Really fascinated at how good you are able to explain. Thanks for the great video!
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.
I just found your channel and the world just makes so much more sense now.
Small piece of feedback: title shoulda been ".equals() and == are not equal"
Thanks for the great video!
.equals() != ==
@@CodingWithJohn even better!
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! :)
😂😂
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 🙂
John, this was an amazing tutorial!
I had a query though; on the objects, do we override the equals() or is it inferred?
we override it
6:15
That was incredibly well explained! Thanks a lot!
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.
Love the Kramer picture in the back, my grandpa has one just like it! Thanks for the amazing videos!
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
This actually helped me understand why some of the code I was writing was initially breaking. Ty!
Had been scratching my head on a case similar to the example at last, luckily this video explained it. Huge thanks :)
I just bought his full Java course. Amazing explanation .
This guy is the best as a learner and teacher guide
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!!!!
this channel always dropping gems. Respect.
Wow, noob here, didnt know those details till you explain it, massive thanks John!
Thank you so much! You solved a bunch of hurdles I was facing while coding in Java. You earned a new Subscriber! By the way, what program are you using to code?
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?.
tus videos tienen un gran valor, muchas gracias por compartir tu conocimiento
Thanks Johnny Sins
Please be polite with your words👍
@@lyrixvibzhe said thank you
@@1blkvincido you know Johnny sins?💀
@@1blkvinciThat's not the right way to say thank you.
Once you learn a thing or two about oops you know exactly what's going on. Thank you for the video
Thanks so much for the video. Genuinely looking forward to the "how to write a good equals method" vid!
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!
Thanks John, your tutorials are very helpful. You are a great teacher, hats off!
Thansk's John. Please don't stop your videos they are awesome
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
Might also be worth mentioning that you can use == with enum's as well.
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
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!
This is just the best explanation..wow👏Thank you for all your videos🙏
I wish you were my lecturer at Uni. You have talent man!
This is the best i have understoon so far...
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).
What’s the codes for .equals() in class Dog?
Thanks John, your tutorials are awesome.
This channel is very very good.
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 ❤
Thanks for the video john seems like refreshing my basics
Thanks John, Mucha Gracias from Canada!
Hey pls make video on comparable comparator interface in java
Thanks. Useful, however you still did not cover how to compare 2 objects on the Dog example staring from 05:08
the last part was really good!
Excellent video as always!
John, please clarify this for me, in text, how would you declare and compare 2 string objects for equality?
Very well explained Jonh, Thanks again ♥
Very clear. Awesome examples and also my eyes love the dark theme ^^
It seems I've found my coding channel. Thanks for the video :)
Thx for your clear presentation Sir
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!".
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.
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 :)
This is awesome! Can you do a video on priority queues and comparators, and how they come together?
But in your strings are immutable video, you said when initializing a string variable java points it to a pre existing string memory address. With that, here hello is already exist when you initialize the second string. Therefore both variable should point to same address, that is using == returns true. ? I am confused plz answer me.
the string itself is probably wrapped in a class and the class stores the reference to the string pool but the objects are initialized in different memory regions
@@lumschente Don't know if it is true, but that makes sense
I was thinking about the same, @john could you please clarify this question
Here is the other video of your we were referring to 🙂
th-cam.com/video/Bj9Mx_Lx3q4/w-d-xo.html
String Pool, the place where are inline strings are saved, that's why you use new String("hello")
thanks a lot you help me to understand the concepts
I love this guy! I am hitting the Like button!
The API contract also states that if you override equals() then you must override the hashcode(), it's an important detail!
Superb sir❤
Good explanation! What about enum comparation? What should I use?
Great video as always. Thank you for your dedication!
Thank you so much, your videos are pretty helpful 😊
Nice job John !
Just the greatest explanation !
Thank you so much.. Your explanation is very clear...!!!
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
Wow thanks man it is so well explain !
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?
Can you do a video sometime on instanceof, thank you.
As a python programmer, I definitely see myself getting confused if I were to ever get into Java. Thanks for the explanation :)
You shouldn't look too deep into the difference between "is" and "=" in python then lol
@@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.
@@JPS13Laptop Java doesn’t use == for object comparison, that was the whole point of this video
@@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.
@@JPS13Laptop that means that you don't understand either "is" in python or "==" in Java
Easy to understand. Thank you.
To the point explanation
This is a gotcha for those coming from C#. Great explanation John!
Amazing explanation, thanks alot
Thanks! Your videos are great!
Can you please make that video you promised on writing a good equals method?
lmao, that head pop up at the beginning cracks me up!
Thanks john 😄
What about StringBuilder & StringBuffer ??
Hello John, please answer why i am getting false in first case?
String str1 = new String("hello");
String str2 = new String("hello");
System.out.println(str1.equals(str2));
and
String str = new String("java");
String rev = new String("avaj");
System.out.println(str.equals(rev));
how string comparision is done, is it character by character?
I think better you recheck 1st case, it has to be true
Amazing explanation. My Uni java lecturer even didn't taught us this important concept. Keep up the great job!
Great lessons as usual. Thanks.
Thank you John
Thanks John!
Why the equals method inside Dog class take an Object type parameter instead of a Dog type parameter?
I don't do Java, but what about enumerations? If they exist does the == work?
Yes, for enums you also use ==
thanks a lot !!! awesome explanation
Love your videos bro. Very helpful. Thanks a lot
Amazing tutorial!
Hello John, after You Ctrl + click on .equals (4:15 min) how did you go back? I mean how to hide all that info that appeared after Ctrl + clicking?
It just opens the file where .equals is defined, just close this file
wow, very well explained. Thank you