No video
Checking Equality in Java ( == vs equals method )
This Java tutorial for beginners explains different ways to check if two variables are equal including ==, the equals() method, and Arrays.equals().
Specifically, we discuss primitive types including int, double, and boolean. Also included are explanations for the array class, ArrayList class, and String class.
Aligned to AP Computer Science A.
🔥 Subscribe To Get More Tutorials: bit.ly/36H70sy 🔥
🖥️ All Java Tutorials: bit.ly/JavaTutorialsKZread 🖥️
#Java #JavaTutorial #JavaTutorials
Пікірлер: 23
📌 Subscribe For The Latest Videos: bit.ly/36H70sy 📌 . 💻 All Java Tutorials: bit.ly/JavaTutorialsKZread 💻 . 🤖 Learn Java In 3 Hours: bit.ly/JavaIn3Hours 🤖
These videos are amazing and help me understand concepts that I didn't even know existed. Thank you bill!
Really liked your video.. Super awesome explanations with just the right amount of info so a person watching the video isn't flooded !
@BillBarnum
2 жыл бұрын
Awesome, thank you!
Seems like there is a typo in 11:00 .. the quotation is not closed inside the parentheses of the println method in the second if statement! Your video is helping me a lot Thanks ^^
@BillBarnum
4 жыл бұрын
Wow, good catch!
God bless you, I've been racking my brain against this for hours and this video was exactly what I needed. Very clear presentation. Your "Primitive vs Reference Type Objects in Memory" was also very helpful. Thanks a lot!
@BillBarnum
4 жыл бұрын
Thanks for the feedback.
great video.
I wish u were my tutor
Good job
Wow this is really cool 🗣💯
@BillBarnum
2 жыл бұрын
Thanks for the feedback. I'm glad you liked the video!
I watched all the ads for you :)
Hi Bill, can we initialize arraylist like this? List myList = new ArrayList(); I mean is this the right way?
@BillBarnum
7 ай бұрын
That would be fine. Alternatively: ArrayList myList = new ArrayList(); ArrayList Video: kzread.info/dash/bejne/mn6jxLF8gLHUo8Y.html&pp=ygUOYXJyYXlsaXN0IGphdmE%3D
👍
@BillBarnum
3 жыл бұрын
Thanks for the feedback!
7:44 can anyone tell me why it returns false,,, but in Arraylist it returns true..
@BillBarnum
2 жыл бұрын
Good question. The Java object class includes an equals method that checks if the variables point at the same object. For classes, like arrays, that inherit the equals from the Java object class, using == and .equals() is equivalent. In classes like ArrayList, the .equals() method was overridden, and it actually checks the VALUES in the objects the variables are pointing at. In those cases, using .equals will return true if the two variables point at different objects with equal values. I don't have a video on it, but if you search KZread for "overriding equals java," you can learn what it means to override the equals method. If you want to learn more about inheritance in general, or overriding in general, I have some videos on those topics: kzread.info/head/PLmpmyPywZ443dRtMleUPoNp2OyiNE45O6
@RakibHasan-455
2 жыл бұрын
@@BillBarnum Thanks man!
7:50 mistake on line a.equals(c) will be true.
@BillBarnum
Жыл бұрын
Syed, This is an example of how confusing it can be to check equality in Java. While they are equivalent arrays, if you compare them that way, it will evaluate to false because the variables aren't pointing at the same object. At 11:20, I talk about the correct way to check the equivalency of two arrays.